Flask

Example

   1 cd ~/tmp
   2 mkdir flaskproject
   3 cd flaskproject
   4 sudo apt install python3-venv
   5 python3 -m venv virtenv
   6 . virtenv/bin/activate
   7 pip install Flask
   8 find . virtenv/

   1 from flask import Flask
   2 
   3 app = Flask(__name__)
   4 
   5 @app.route("/")
   6 def hello_world():
   7     return "<p>Hello World from Flask!</p>"

   1 export FLASK_APP=flaskproj
   2 flask run  --host=0.0.0.0
   3 # http://127.0.0.1:5000/
   4 #  if the file is named app.py or wsgi.py, you don’t have to set the FLASK_APP environment
   5 

Python/Flask (last edited 2021-06-18 13:58:37 by localhost)