install flask

  1. Install Flask using pip:
pip install Flask
  1. Create a directory for your Flask project:
mkdir your_project_name
cd your_project_name
  1. Create a virtual environment (optional but recommended):
python -m venv venv
  1. Activate the virtual environment:
  2. For Windows: bash venv\Scripts\activate
  3. For macOS/Linux: bash source venv/bin/activate

  4. Create a Python script for your Flask application, e.g.,, and open it in a text editor.

  5. Import the Flask module and create a Flask web server instance: python from flask import Flask app = Flask(__name__)

  6. Define a route and a function to handle the route: python @app.route('/') def hello(): return 'Hello, World!'

  7. Add the following code at the end of your script to run the Flask application: python if __name__ == '__main__':

  8. Save your script and go back to the terminal.

  9. Run your Flask application: bash python

  10. Open a web browser and navigate to or http://localhost:5000/. You should see "Hello, World!" displayed.

  11. To stop the Flask application, press Ctrl+C in the terminal.

You have successfully installed Flask, created a basic Flask application, and run it locally.