Skip to main content

A sorta familiar HTTP framework.

Project description

Responder: a familiar HTTP Service Framework for Python

Build Status Documentation Status image image image image

The Python world certainly doesn't need more web frameworks. But, it does need more creativity, so I thought I'd spread some Hacktoberfest spirit around, bring some of my ideas to the table, and see what I could come up with.

import responder

api = responder.API()

@api.route("/{greeting}")
async def greet_world(req, resp, *, greeting):
    resp.text = f"{greeting}, world!"

if __name__ == '__main__':
    api.run()

That async declaration is optional. View documentation.

This gets you a ASGI app, with a production static files server pre-installed, jinja2 templating (without additional imports), and a production webserver based on uvloop, serving up requests with gzip compression automatically.

Testimonials

"Pleasantly very taken with python-responder. @kennethreitz at his absolute best." —Rudraksh M.K.

"ASGI is going to enable all sorts of new high-performance web services. It's awesome to see Responder starting to take advantage of that." — Tom Christie author of Django REST Framework

"I love that you are exploring new patterns. Go go go!" — Danny Greenfield, author of Two Scoops of Django

"Love what I have seen while it's in progress! Many features of Responder are from my wishlist for Flask, and it's even faster and even easier than Flask!" — Luna C.

More Examples

See the documentation's feature tour for more details on features available in Responder.

Installing Responder

Install the latest release:

$ pipenv install responder --pre
✨🍰✨

Or, install from the development branch:

$ pipenv install -e git+https://github.com/kennethreitz/responder.git#egg=responder

Only Python 3.6+ is supported.

The Basic Idea

The primary concept here is to bring the niceties that are brought forth from both Flask and Falcon and unify them into a single framework, along with some new ideas I have. I also wanted to take some of the API primitives that are instilled in the Requests library and put them into a web framework. So, you'll find a lot of parallels here with Requests.

  • Setting resp.text sends back unicode, while setting resp.content sends back bytes.
  • Setting resp.media sends back JSON/YAML (.text/.content override this).
  • Case-insensitive req.headers dict (from Requests directly).
  • resp.status_code, req.method, req.url, and other familiar friends.

Ideas

  • Flask-style route expression, with new capabilities -- all while using Python 3.6+'s new f-string syntax.
  • I love Falcon's "every request and response is passed into to each view and mutated" methodology, especially response.media, and have used it here. In addition to supporting JSON, I have decided to support YAML as well, as Kubernetes is slowly taking over the world, and it uses YAML for all the things. Content-negotiation and all that.
  • A built in testing client that uses the actual Requests you know and love.
  • The ability to mount other WSGI apps easily.
  • Automatic gzipped-responses.
  • In addition to Falcon's on_get, on_post, etc methods, Responder features an on_request method, which gets called on every type of request, much like Requests.
  • A production static file server is built-in.
  • Uvicorn built-in as a production web server. I would have chosen Gunicorn, but it doesn't run on Windows. Plus, Uvicorn serves well to protect against slowloris attacks, making nginx unnecessary in production.
  • GraphQL support, via Graphene. The goal here is to have any GraphQL query exposable at any route, magically.
  • Provide an official way to run webpack.

hacktoberfest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

responder-0.3.3.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

responder-0.3.3-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file responder-0.3.3.tar.gz.

File metadata

  • Download URL: responder-0.3.3.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for responder-0.3.3.tar.gz
Algorithm Hash digest
SHA256 55e24e7b7bc960f45435863f3768edcfe7e2c1ab1b5d9f09de9d7f47c3cb316f
MD5 b4b21c8265cb833453c0b424d785b2d5
BLAKE2b-256 a7569be11b01fd13a2532ddbce9efa306f2b628dee9f753dff17843484d58daf

See more details on using hashes here.

File details

Details for the file responder-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: responder-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for responder-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 840a8706d804eb48c638135656d6fc7964f5d9209f25b50e31809dd903993506
MD5 8bc61838fd4c587d5fa0868850bee760
BLAKE2b-256 2df66e07a76612cc75a50d0fd2dc19d2ad4bee612a1815a13d8bda9a4d117be6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page