My Brain Cells

Easiest (and best) learning materials for anyone with a curiosity for machine learning and artificial intelligence, Deep learning, Programming, and other fun life hacks.

Setup flask in VS Code

Prerequisites:

  1. Install the Python extension in vs code.

  2. Install a version of Python 3/

  3. On Windows, make sure the location of your Python interpreter is included in your PATH environment variable.


Steps:
  1. Create a project folder for this tutorial, such as hello_flask.

  2. In that folder, use the following command (as appropriate to your computer) to create and activate a virtual environment named .venv based on your current interpreter:

    # macOs
    python3 -m venv .venv
    source .venv/bin/activate

    # Windows
    py -3 -m venv .venv
    .venvscriptsactivate
    3. Open the project folder in VS Code.
    4. In VS Code, open the Command Palette (View > Command Palette or (Ctrl+Shift+P)). Then select the Python: Select Interpreter.
    5. Install Flask in the virtual environment terminal.
        python -m pip install flask

    6. Now create a app.py file
    
    # app.py
    from flask import Flask
    app = Flask(__name__)
    @app.route(“/”)
    def home():
    return “Hello, Flask!”
    7. run the app by entering python -m flask run

Anthony

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top