
Python and Flask are awesome for building static pages and web apps but most tutorials show how to run it from a Linux shell. If you want to run it natively in Windows with Powershell, here are a few tips to get started.
- Use py
- Create your virtual environment
> mkdir C:\ProjectsPythonNewProject
> cd C:\ProjectsPythonNewProject
> py -3 -m venv .venv
> .venv/scripts/activate
You are in your virtual environment when the prompt shows venv
> (.venv) PS C:ProjectsPythonNewProject>
Now that you are inside your virtual environment you want to check for packages from pip and install flas
Check packages with:
pip list
2. If needed, upgrade pip:
- cd to /Scripts
- run python.exe -m pip install –upgrade pip
3. Install Flask and other libraries for your project requirements
pip install flask
pip install requests

Create your app.py on the root of your project folder (C:ProjectsPythonNewProject)

Configure the app.py to run with Flask and add some HTML to test
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "<h1 style='color: blue'>Hello World!!!</h1>"
if __name__ == "__main__":
app.run()
- Change environment variable to run dev or prod:
- Set your variable to your app: $env:FLASK_APP=.app.py
Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: “.app.py”.
- Set the variable to desired environment and use flask run to start:
- $env:FLASK_ENV = “development” + flask run
- Great for getting debug info, NOT FOR PROD!!
- $env:FLASK_ENV = “development” + flask run

We can now run and test with
> $env:FLASK_ENV = "Production"
> flask run
Result:
