tiny

A small web framework for learning about web frameworks.


License
MIT
Install
pip install tiny==0.1.3

Documentation

Tiny - The tiniest possible web framework. Inspired by Flask, Bottle, and Itty.

To Install:

pip install tiny

To create a simple app:

import tiny, os

# Creates the app object.
app = tiny.TinyApp()

# Sets the path for the app to find HTML templates.
app.set_template_path(os.path.abspath('templates'))

## Routing ###

@app.route('/')
def index(request):
    """Defines the index view, accessible at '/'."""

    # Creates a response comprised of the content of index.html and rendered template variables.
    content = tiny.TinyResponse(app.render('index.html', template_var="Hello world"))

    # Whatever is returned in a view will display on the page.
    return content # Hello world

## HTTP Errors ##

@app.route('/505')
def error(request):

    content = tiny.TinyResponse('HTTP Version Not Supported', 505)
    return content

if __name__ == '__main__':
    tiny.run_app(app) # Will be accessible at localhost:8080 by default.

To create a template:

<!-- index.html -->

{{ template_var }}

To run the test suite:

python tests/tests.py

>> ......
>> ----------------------------------------------------------------------
>> Ran 6 tests in 0.001s
>>
>> OK