|
Size: 174
Comment:
|
← Revision 7 as of 2026-03-28 15:34:25 ⇥
Size: 1345
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| <<TableOfContents(2)>> | |
| Line 5: | Line 6: |
== Example == {{{#!highlight sh cd ~/tmp mkdir flaskproject cd flaskproject sudo apt install python3-venv python3 -m venv venv . venv/bin/activate # pip install -r requirements.txt pip install Flask find . venv/ ./venv/bin/python -V ./venv/bin/python }}} === static/app.css === {{{#!highlight css p{ text-align: center; } }}} === static/app.js === {{{#!highlight javascript document.addEventListener("DOMContentLoaded", (event) => { console.log("DOM is ready!"); }); }}} === templates/index.html === {{{#!highlight html <html> <head> <link href="static/app.css" rel="stylesheet"> <script src="static/app.js"></script> </head> <body> <p>Hello Flask</p> </body> </html> }}} === flaskproj.py === {{{#!highlight python from flask import Flask, render_template app = Flask(__name__) @app.route("/") def hello_world(): return render_template("index.html") }}} {{{#!highlight bash export FLASK_APP=flaskproj flask run --host=0.0.0.0 # http://127.0.0.1:5000/ # if the file is named app.py or wsgi.py, you don’t have to set the FLASK_APP environment }}} |
Flask
- Micro web development framework
- Flask depends on the Jinja template engine and the Werkzeug WSGI toolkit.
Example
static/app.css
1 p{ text-align: center; }
static/app.js
templates/index.html
