A web application library.
Project description
Pump is a low-level library for developing web applications in Python. It
is meant to improve on WSGI by providing a clean, developer-friendly API.
Heavily inspired by Clojure's Ring and Ruby's Rack.
Pump apps are easily converted to WSGI apps. WSGI middleware can also be
converted to Pump middleware.
EXAMPLE.
# test.py
import pump
def app(req):
return {"status": 200, "headers": {"content_type": "text/plain"},
"body": "Hello, world!"}
pump.adapters.serve_with_paste(app, {"port": 3000})
This requires the Paste WSGI server <http://pythonpaste.org> to run.
DESCRIPTION.
-- A Pump app is a function that takes a Pump request and returns a Pump
response.
-- A Pump request is a dict with the following keys.
-- server_port
Corresponds to SERVER_PORT in WSGI's environ.
-- server_name
Corresponds to SERVER_NAME in WSGI's environ.
-- remote_addr
Corresponds to REMOTE_ADDR in WSGI's environ (not required by specs).
-- uri
Corresponds to RAW_URI in WSGI's environ, or PATH_INFO if it is not
given.
-- query_string
The portion of the request URL that follows the "?". Corresponds to
QUERY_STRING in WSGI's environ.
-- scheme
"http" or "https". Corresponds to wsgi.url_scheme in WSGI's environ.
-- method
"GET", "POST", etc. Corresponds to REQUEST_METHOD in WSGI's environ.
-- headers
A dict containing the request headers. Each key-value pair corresponds
to a key in WSGI's environ starting with "HTTP_". If there are multiple
headers for a single key, headers[key] will be the list of values.
-- content_type
Corresponds to CONTENT_TYPE in WSGI's environ.
-- content_length
Corresponds to CONTENT_LENGTH in WSGI's environ.
-- body
The HTTP request body as a stream. Corresponds to wsgi.input in WSGI's
environ.
-- A Pump response is a dict with the following keys.
-- status
An integer, e.g. 200, 404.
-- headers
A dict containing the response headers, e.g.
{'content_type': 'text/html'}.
-- body
A string containing the body of the response.
is meant to improve on WSGI by providing a clean, developer-friendly API.
Heavily inspired by Clojure's Ring and Ruby's Rack.
Pump apps are easily converted to WSGI apps. WSGI middleware can also be
converted to Pump middleware.
EXAMPLE.
# test.py
import pump
def app(req):
return {"status": 200, "headers": {"content_type": "text/plain"},
"body": "Hello, world!"}
pump.adapters.serve_with_paste(app, {"port": 3000})
This requires the Paste WSGI server <http://pythonpaste.org> to run.
DESCRIPTION.
-- A Pump app is a function that takes a Pump request and returns a Pump
response.
-- A Pump request is a dict with the following keys.
-- server_port
Corresponds to SERVER_PORT in WSGI's environ.
-- server_name
Corresponds to SERVER_NAME in WSGI's environ.
-- remote_addr
Corresponds to REMOTE_ADDR in WSGI's environ (not required by specs).
-- uri
Corresponds to RAW_URI in WSGI's environ, or PATH_INFO if it is not
given.
-- query_string
The portion of the request URL that follows the "?". Corresponds to
QUERY_STRING in WSGI's environ.
-- scheme
"http" or "https". Corresponds to wsgi.url_scheme in WSGI's environ.
-- method
"GET", "POST", etc. Corresponds to REQUEST_METHOD in WSGI's environ.
-- headers
A dict containing the request headers. Each key-value pair corresponds
to a key in WSGI's environ starting with "HTTP_". If there are multiple
headers for a single key, headers[key] will be the list of values.
-- content_type
Corresponds to CONTENT_TYPE in WSGI's environ.
-- content_length
Corresponds to CONTENT_LENGTH in WSGI's environ.
-- body
The HTTP request body as a stream. Corresponds to wsgi.input in WSGI's
environ.
-- A Pump response is a dict with the following keys.
-- status
An integer, e.g. 200, 404.
-- headers
A dict containing the response headers, e.g.
{'content_type': 'text/html'}.
-- body
A string containing the body of the response.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pump-0.1.0.tar.gz
(9.7 kB
view hashes)