Via is a Django inspired Flask extension for url routing, allowing you to define routes and have them automatically added to the application.
Python Makefile CSS
Permalink
Failed to load latest commit information.
docs Fix some Blueprint docs formatting issues. Jul 7, 2014
flask_via Version bumps w/ Changelog Jul 16, 2014
tests Deprecated Basic for Functional router May 19, 2014
.coveragerc
.gitignore
.landscape.yaml Added landscape cnfig May 5, 2014
.travis.yml Improved test suite w/ pytest May 12, 2014
CHANGELOG.rst Changelog Update and Version Bump Jan 6, 2015
CONTRIBUTORS.rst
LICENSE Basic example + basic readme May 1, 2014
MANIFEST.in
Makefile Improved test suite w/ pytest May 12, 2014
README.rst Flat badges Jul 31, 2014
REQS.DEVELOP.txt
REQS.TESTING.txt
REQS.txt Main requirements file w/ flask requirement May 3, 2014
VERSION Changelog Update and Version Bump Jan 6, 2015
setup.cfg
setup.py Fix setup.py requirements reading to enable bdist_wheel Jan 6, 2015

README.rst

Flask-Via

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.

Travis build status on Master Branch Test Coverage Number of PyPI downloads Latest PyPI version MIT License

Example

from flask import Flask
from flask.ext.via import Via
from flask.ext.via.routers.default import Functional

app = Flask(__name__)

def foo(bar=None):
    return 'Foo View!'

routes = [
    Functional('/foo', foo),
    Functional('/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