Run a Flask API from CMD

Step 1: Install Flask

pip install Flask

Step 2: Create a Flask app file (e.g., with the following content:

from flask import Flask

app = Flask(__name__)

def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':

Step 3: Open CMD and navigate to the directory containing your file.

Step 4: Set the Flask app environment variable:


Step 5: (Optional) Enable debug mode for automatic reloading:

set FLASK_ENV=development

Step 6: Run the Flask app:

flask run

Step 7: Open a web browser and go to or http://localhost:5000/ to see your Flask app running.