How to install flasker
- Download and install ActivePython
- Open Command Prompt
pypm install flasker
Flasker is now deprecated.
Consider using Kit instead, which allows YAML configuration files, running multiple projects side by side and more.
What Flasker is!
- A one stop .cfg configuration file for Flask, Celery and SQLAlchemy.
- A simple pattern to organize your project via the flasker.current_project proxy (cf. Quickstart).
- A command line tool from where you can launch the Flask buit in Werkzeug server, start Celery workers and the Flower tool, and run a shell in the current project context.
What Flasker isn't?
- A simplified version of Flask, Celery, and SQLAlchemy. Some knowledge of these frameworks is therefore required.
This short guide will show you how to get an application combining Flask, Celery and SQLAlchemy running in moments (the code is available on GitHub in examples/basic/).
The basic folder hierarchy for a Flasker project looks something like this:
Where conf.cfg is:
The MODULES option contains the list of python modules which belong to the project. Inside each of these modules we can use the flasker.current_project proxy to get access to the current project instance (which gives access to the configured Flask application, the Celery application and the SQLAlchemy database session registry). This is the only option required in a Flasker project configuration file.
Here is a sample app.py:
Once these two files are in place, we can already start the server! We simply run (from the command line in the project/ directory):
We can check that our server is running for example using Requests (if we navigate to the same URL in the browser, we would get similarly exciting results):
Configuring your project
In the previous example, the project was using the default configuration, this can easily be changed by adding options to the conf.cfg file. Here is an example of a customized configuration file:
For an exhaustive list of all the options available, please refer to the documentation on GitHub Pages.
Finally, of course, all your code doesn't have to be in a single file. You can specify a list of modules to import in the MODULES option, which will all be imported on project startup. For an example of a more complex application, you can check out the code in examples/flisker.
Under the hood, on project startup, Flasker configures Flask, Celery and the database engine and imports all the modules declared in MODULES (the configuration file's directory is appended to the python path, so any module in our project/ directory will be accessible).
There are two ways to start the project.
The simplest is to use the flasker console tool:
This will list all commands now available for that project:
- server to run the Werkzeug app server
- worker to start a worker for the Celery backend
- flower to run the Flower worker management app
- shell to start a shell in the current project context (using IPython if it is available)
Extra help is available for each command by typing:
Or you can load the project manually:
This is useful for example if you are using a separate WSGI server or working from an IPython Notebook.
To read more on how to user Flasker and configure your Flasker project, refer to the documentation on GitHub pages.
Flasker also comes with extensions for commonly needed functionalities:
- Expanded SQLAlchemy base and queries
- ReSTful API
- Authentication via OpenID (still alpha)