Skip to content

Instantly share code, notes, and snippets.

@mpirnat
Created October 7, 2012 04:49
Show Gist options
  • Save mpirnat/3847137 to your computer and use it in GitHub Desktop.
Save mpirnat/3847137 to your computer and use it in GitHub Desktop.
Example of a well-factored Flask app?
A Question
==========
Is there a good example of a well-factored Flask app that keeps its
concerns nicely separated?
Admittedly I'm brand new and only really skimming the docs at this
point, but it seems like I *have* to instantiate a Flask app right
away so that I can use the @app.route decoration to set up routes
on view methods.
And it also seems like it wants me to lean on the magic 'g' globals
to get at a database connection that might not exist if I haven't
instantiated an app yet, which feel gross for testability. The
module-level globalness of 'request' freaks me out a bit too.
I like to keep my models isolated from my persistence, and all of
that isolated from the app server, routing, request handling, etc.
On a somewhat related note, is it just me, or are the docs kind of
bad in spite of being rather copious? I find them alternately too
simplistic or too obtuse/impractical.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment