FastAPI, Django and Flask comparison
Django | FastAPI | Flask | |
---|---|---|---|
Release | 2005 | 2018 | 2010 |
License | 3-clause license | MIT License | BSD 3-Clause |
url | djangoproject.com | fastapi.tiangolo.com | flask.palletsprojects.com |
pip install Django
django-admin startproject todoapp
python manage.py migrate
python manage.py runserver
python manage.py startapp todolist
- add 'todolist' to INSTALLED_APPS
- implement todolist.views.py and create todolist.urls.py
- add urls to todoapp.urls.py
- add templates folder and file
- add "templates" to DIR in settings.py
- modify view: return render...
- implement todolist.models.py
manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
- Adding models to the administration site:
- todolist.admin.py: admin.site.register(Todo)
- login to admin
- add {% csrf_token %} to template
- implement views
pip install fastapi
pip install "uvicorn[standard]"
pip install python-multipart sqlalchemy jinja2
uvicorn app:app --reload
python3 -m venv venv
. venv/bin/activate
pip install Flask
pip install Flask-SQLAlchemy
export FLASK_APP=app.py
export FLASK_ENV=development
flask run