Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Question: Is there a way to create application modules in the same style of Django modules (shippable extensions to an application) in Flask?

I've read about Flask blueprints, but that didn't seem to have the same angle... seemed to be more shippable libraries rather than a module of an application.



Blueprints are the same angle(better IMO). Develop the blueprint as a standalone module[1](templates, url rules, static files, before handlers...), and the mount it on the main application.

[1] Not python modules. I say module in the abstraction sense.

For eg, you can create a blueprint comments, define url rules('/', '/new', ':id/edit'...), add authentication to before handler(check before create, delete, edit), and then mount it on the main application.

app.register_blueprint(comments, url_prefix='/comments')

You can have blueprints which are self contained modules(comments), blueprints which just add jinja extensions, blueprints which bring in static assets etc etc. What does Django apps do which blueprints don't?





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: