Flask-Via adds Django style url routing configuration.
Project description
Inspired by the Django URL configuration system, Flask-Via is designed to add similar functionality to Flask applications which have grown beyond a simple single file application.
Example
from flask import Flask
from flask.ext.via import Via
from flask.ext.via.routers.default import Basic
app = Flask(__name__)
def foo(bar=None):
return 'Foo View!'
routes = [
Basic('/foo', foo),
Basic('/foo/<bar>', foo, endpoint='foo2'),
]
via = Via()
via.init_app(app, route_module='flask_via.examples.basic')
if __name__ == "__main__":
app.run(debug=True)
Why?
Growing your application can be quite difficult when it’s not always clear where and how your routes are discovered. This can lead to a cluttered application factory method when all your routes are defined at application creation - resulting in code which is difficult to maintain, not to mention messy.
A better solution is to define your routes in a routes.py and automatically load them at application start up. This is what Flask-Via helps to do.
Third party Flask extensions don’t always follow the same conventions for adding routes to an application, so Flask-Via has been designed to be easy for developers to write their own custom routers. For an example of this, take a look at the bundled Flask-Restful Resource router.
If you do write a custom router that is useful to you, it will probably be useful to someone else so please do contribute back :)
Links
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
File details
Details for the file Flask-Via-2014.05.06.tar.gz
.
File metadata
- Download URL: Flask-Via-2014.05.06.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9851e39eb5192e5ddef7874899f2f0e52961249724061b9d1d22261ad234606 |
|
MD5 | 97e246b12da5f897f4c3b6db4daf3c1e |
|
BLAKE2b-256 | e749e40a8f434e9b086fcbb6207b30cc04e04e73168325e4c4754c2ab5bfb6f9 |