Command line tool. Note this post has been updated at 06 Jan 2014 to notice about a follow up article. You can read about a follow up article containing an example Flask application made with Flask command line tool.
Command line tool for the Python Flask web framework
Note this post has been updated at 03 Jan 2014 to reflect some changes made in the command line tool and more specifically to the resulting layout, see the screenshots session No 4.
Although this is not a post about Flask framework itself and I am not the best to introduce it to you because probably you already know much more things from me; i feel that at least must give two lines of information for potential Flask newcomers.
Flask is a modular micro web framework written in Python, easy to start but also powerful enough to let you create serious web applications. Contrary to Django which is very good and the norm among Python web developers, Flask is minimalistic leaving out the object relation mapper and other goodies. You can get them in the form of extensions (called blueprints in Flask world). For example you can integrate an object relation mapper for SQLAlchemy (Flask-SQLAlchemy), WTForms (Flask-WTF) for user input through HTML forms and many more. For further information check the links bellow.
So this post is about a command line tool (i call it Flaskapp and lives in my home folder ~/bin as flask so i can invoke it from the console easily) that uses Flask and many of the offered extensions and can be used to save the developer from boilerplate code and typing. I created the tool while reading about Flask here.
The short version describes what the tool can do and what it needs in order to do its thing. For more details check the links bellow:
What it does
Creates directory structures for new Flask based projects
Follows a modular approach in Flask based applications, that is all views, models, forms live inside Blueprints created by the tool
Creates blueprints, views, models, templates, forms and a tests file.py ready for use.
Upon project creation it can download and register in the base template jQuery and Bootstrap (both are optional))
Creates configuration files for Nginx and uWSGI ready to be copied to /etc/ configuration directories enabling you instant deployment to servers
A bit of the Ruby on Rails command line tool and its generators but don’t expect refined approach.
Requirements, you must have the following Python packages installed
Requests [http://docs.python-requests.org/en/latest/] pip install requests
Flask [flask.pocoo.org] pip install flask
Jinja2 [jinja.pocoo.org] installed with Flask
Werkzeug [werkzeug.pocoo.org] installed with Flask
SQLAlchemy [www.sqlalchemy.org] pip install sqlalchemy
flask-SQLAlchemy [pythonhosted.org/Flask-SQLAlchemy/] pip install flask-sqlalchemy
WTForms [wtforms.simplecodes.com] pip install wtforms
flask-WTF [pythonhosted.org/Flask-WTF/] pip install Flask-WTF
Project’s page: http://projects.iccode.net/stef/flaskapp
Flask framework: http://flask.pocoo.org/
Jinja2 the template engine used in Flask: http://jinja.pocoo.org/
Werkzeug the WSGI library used in Flask: http://werkzeug.pocoo.org/
Requests is an HTTP library easy to use: http://docs.python-requests.org/en/latest/
SQLAlchemy is an Object Relational Mapper (ORM) for the Python language: http://www.sqlalchemy.org/
Flask-SQLAlchemy is a Flask extension providing integration with SQLAlchemy: http://pythonhosted.org/Flask-SQLAlchemy/
WTForms is a form creation – validation library for Python: http://wtforms.readthedocs.org/en/latest/
Flask-WTF is a Flask extension providing integration with WTForms: https://flask-wtf.readthedocs.org/en/latest/
Please help us spread this information to as many people as possible. All you have to do is click on one of the buttons above. We thank you in advance for your great help.
Thanks for sharing