Flask-Now is a Flask Application Generator/Build-Tool runs via CLI
Since Flask is commonly used in kickstarting a project, developers shouldn't waste their time with creating folders like static/css, static/js, configuration, controllers, models etc. Aim of Flask-Now is auto generating necessity folders and files according to your architectural pattern and semi-automatically installing desired flask extensions. Since Flask is very flexible microframework, it may fit many architectural pattern. Currently following patterns can be auto generated using Flask-Now:
Flask-Now supports two different patterns:
- It is a very simple flask application structure for very small applications
/your_project_folder
venv
run.py
config.py
requirements.txt
- As suggested in official tutorial, Flask Now has a similar folder structure which is called as MVC:
/your_project_folder
venv
run.py
requirements.txt
/project
__init__.py
controller.py
models.py
config.py
/static
/css
style.css
/js
script.js
/templates
index.html
You can auto-install following Flask Extensions while building your architecture: List of Extensions
Also supports:
- Flask-Bootstrap
- Python 3.x
- Virtualenvironment
- pip3
Let me explain this project with an example. Assume that we want to create an Flask Application called flaskr
- Install flask-now with pip, this will add an executable file to your /bin with the name flask-now which is out application:
pip install --user flask-now
- Create a project folder:
mkdir flaskr && cd flaskr
- Setup a virtualenvironment:
virtualenv -p python3 venv
- Activate it:
source venv/bin/activate
- Important part starts, we will run flask-now with command line arguments, let's assume that we need Flask-WTF and Flask-Bootstrap in MVC patern:
flask-now -mvc wtf bootstrap
If you run the code above, Flask-Now will do the all job for you.
- If you want to create a simple structure that I mentioned above, don't pass architecture pattern(
-mvc
) arguments to flask-now. Example:
flask-now wtf bootstrap
- As you can understand from the example we drop Flask keyword while installing flask extensions to our project. For example:
If we want to install Flask-Admin, we just drop "Flask-" part at the beginning of the extension and passing admin as an argument to flask-now.
Some examples which may confuse you:
Flask-Rest-Jsonapi -> rest-jsonapi
Frozen-Flask -> frozen
flask-now -mvc frozen rest-jsonapi wtf bootstrap admin
And that's it. Your simple flask app is ready. Run it!
python3 run.py
This application initially have 3 configuration objects in config.py
:
DEBUG=True
SECRET_KEY
= It is generated automatically as suggested in(using os.urandom()
) Flask Quick Start
SERVER_NAME="127.0.0.1:5000"
To uninstall :
pip uninstall flask-now
- Adding more architectural patterns.
- Adding more options for configuration file.
- Adding smart code generation according to desired extensions.(for example if you install Flask-SqlAlchemy, sample model, imports and db configurations will be ready)
Please feel free to contribute to this project, open issues, fork it, send pull requests.
If your flask extension does not included in this software please feel free to send me an email.
You can also send email to my mail adress.ozanonurtek@gmail.com
Happy coding 🤘