Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
The itty-bitty Python web framework.
branch: master

This branch is 7 commits ahead, 6 commits behind toastdriven:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
.gitignore
AUTHORS
LICENSE
README.rst
__init__.py
benchmarks.rst
itty.py
setup.py

README.rst

This is a modified version of itty.py which attempts to add support for the HTTP 'Accept:' request header.

example code:

@get('/')
@accept('text/plain')
def index(request):
    return "Hello, World!\n"

@get('/')
@accept('text/xml')
def index(request):
    return '<?xml version="1.0"?><greeting>Hello, World!</greeting>\n'

@get('/')
@accept('application/json')
def index(request):
    return '{ "greeting": "Hello, World!" }\n'

@get('/')
def index(request):
    return "<html><body>Hello, World!</body></html>\n"

output:

$ wget -q -O - --header='Accept: text/plain' http://localhost:8080
Hello, World!

$ wget -q -O - --header='Accept: text/xml' http://localhost:8080
<?xml version="1.0"?><greeting>Hello, World!</greeting>

$ wget -q -O - --header='Accept: application/json' http://localhost:8080
{ "greeting": "Hello, World!" }

$ wget -q -O - --header='Accept: text/html' http://localhost:8080
<html><body>Hello, World!</body></html>

This is just a first stab to flesh out the idea.

Limitations (i.e. things which could be improved upon):

  • You have to define your methods in order from most specific to least specific.
  • Wildcards and 'q' aren't supported yet.

Feel free to take this idea and run with it. Have fun! Jason Pepas jason@pepas.com

itty.py

The itty-bitty Python web framework.

itty.py is a little experiment, an attempt at a Sinatra influenced micro-framework that does just enough to be useful and nothing more.

Currently supports:

  • Routing
  • Basic responses
  • Content-types
  • HTTP Status codes
  • URL Parameters
  • Basic GET/POST/PUT/DELETE support
  • User-definable error handlers
  • Redirect support
  • File uploads
  • Header support
  • Static media serving

Beware! If you're looking for a proven, enterprise-ready framework, you're in the wrong place. But it sure is a lot of fun.

Example

from itty import get, run_itty

@get('/')
def index(request):
    return 'Hello World!'

run_itty()

See examples/ for more usages.

Other Sources

A couple of bits have been borrowed from other sources:

Thanks

Thanks go out to Matt Croydon & Christian Metts for putting me up to this late at night. The joking around has become reality. :)

Something went wrong with that request. Please try again.