How to Install Flask with Nginx and Gunicorn on Debian 12

Published: 14 December 2023
on channel: MivoCloud
346
42

Flask is a microframework written in Python for developing modern web applications and API (Application Programming Interface). It's based on the Werkzeug toolkit and Jinja2 template. Instead of using complex architecture, Flask is a small web framework that easy-to-extent the core and is easy to learn because Flask has less code. Flask doesn't include the ORM but still has cool features like URL routing and a template engine.

In this video i will show you how to install Flask and Gunicorn on your server.

Useful Links:
VPS/VDS - https://www.mivocloud.com/

WARNING - ANGLED BRACKETS AREN'T ALLOWED IN DESCRIPTION SO BE ATTENTIVE TO THE VIDEO IN NANO EDITOR

Commands Used:
sudo apt install python3 python3-pip python3-venv nginx supervisor
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
python --version
pip --version
python -m venv -v
systemctl status nginx
systemctl status supervisor
mkdir -p ~/testapp; cd ~/testapp
python -m venv venv
source venv/bin/activate
pip install flask gunicorn
nano testapp.py

testapp.py
from flask import Flask, render_template # importing the render_template function

app = Flask(__name__)
route to index page
@app.route("/")
def hello():
return render_template('index.html')

if _name_ == ' __main__':
app.run(debug=True)

mkdir -p templates
nano templates/index.html

html
body
h1centerHello Flask - Nginx and Gunicorn Debian 12!/center/h1
/body
/html

flask --app testapp run
nano wsgi.py


import testapp Flask application
from testapp import app

if _name_ == "__main__":
app.run(debug=True)

gunicorn -w 4 --bind 0.0.0.0:8080 wsgi:app


Watch video How to Install Flask with Nginx and Gunicorn on Debian 12 online without registration, duration hours minute second in high quality. This video was added by user MivoCloud 14 December 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 346 once and liked it 42 people.