Skip to main content

This is a recreation of the popular python package, Flask.

Project description

finnsflask

This is a recreation of the popular python package, Flask.

Usage

The base

For a project with no endpoints import the module then create a instance with:

app = finnsflask.FinnsFlask()

Then start the app with:

if __name__ == "__main__":
    app.listen()

Endpoints

To declare an endpoint, between your app declaration and when you start the app, put:

@app.route('/<path>')
def index(request: finnsflask.HTTPRequest):
    return finnsflask.HTTPResponse("<h1>Real Finnventor is awesome</h1>", 200)

Templates

finnsflask uses jinja2 as a templating system. To use a jinja2 template, use a route declaration like the following:

@app.route("/<path>")
def index(request: finnsflask.HTTPRequest):
    return finnsflask.HTTPResponse.load_template('<path-to-jinja2-template>', <template-args>)

Cookies

To get a cookie, use the following inside of your route declaration:

cookies = request.getCookies()

To set a cookie, use a route declaration like the following:

@app.route("/<path>")
def index(request: finnsflask.HTTPRequest):
    response = finnsflask.HTTPResponse()
    response.setCookie("<key>", "<value>")
    return response

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

finnsflask-1.2-py2.py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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