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
Смотрите видео How to Install Flask with Nginx and Gunicorn on Debian 12 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь MivoCloud 14 Декабрь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 346 раз и оно понравилось 42 людям.