Python/Flask: Difference between revisions
< Python
(Created page with "== Flask == == Installation == ## Linux / macOS mkdir myproject cd myproject # python3 -m venv .flask python3 -m venv .venv . .venv/bin/activate ## Windows mkdir myproject cd myproject py -3 -m venv .venv .venv\Scripts\activate ## Next Common Step # pip install Flask pip3 install Flask # End deactivate References: * https://flask.palletsprojects.com/en/stable/installation/ == Quick Start == Hello World helloworld.py <pre> from flask import Flask...") |
|||
| Line 44: | Line 44: | ||
Run the server: | Run the server: | ||
flask --app helloworld run | flask --app helloworld run | ||
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. | |||
Note: | |||
* Running on http://127.0.0.1:5000 | |||
Test the server: | |||
curl http://127.0.0.1:5000 | |||
<p>Hello, World!</p> | |||
References: | References: | ||
* https://flask.palletsprojects.com/en/stable/quickstart/ | * https://flask.palletsprojects.com/en/stable/quickstart/ | ||
Revision as of 22:05, 13 December 2025
Flask
Installation
## Linux / macOS mkdir myproject cd myproject # python3 -m venv .flask python3 -m venv .venv . .venv/bin/activate
## Windows mkdir myproject cd myproject py -3 -m venv .venv .venv\Scripts\activate
## Next Common Step # pip install Flask pip3 install Flask
# End deactivate
References:
Quick Start
Hello World
helloworld.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
Run the server:
flask --app helloworld run
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
Note:
* Running on http://127.0.0.1:5000
Test the server:
curl http://127.0.0.1:5000
Hello, World!
References: