Running the Dev Server
During development you typically run:
flask runflask run
This starts Werkzeug’s development server.
Typical output
You’ll usually see:
- the URL (like
http://127.0.0.1:5000http://127.0.0.1:5000) - that it’s a development server
Host and port
- Default host:
127.0.0.1127.0.0.1(only accessible from your machine) - Default port:
50005000
You can change them:
flask run --host 0.0.0.0 --port 8000flask run --host 0.0.0.0 --port 8000When should you use 0.0.0.00.0.0.0?
Use it when you want access from another device on your network.
Be careful: exposing dev servers is not recommended on public networks.
What happens when you visit the page?
- Browser connects to the host/port
- Sends
GET /GET / - Dev server forwards to Flask app
- Flask finds a matching route and runs your view function
- Response is returned
If you get a 404, it usually means:
- you didn’t define the route, or
- your URL doesn’t match the route rule
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
