How to setup environment variables for `flask run` on Windows?

前端 未结 14 1925
囚心锁ツ
囚心锁ツ 2021-02-04 10:19

I just started learning flask and I am stuck at setting up the Flask environment variables. I don\'t know how to setup the environment variables. Whenever I use the flask

14条回答
  •  庸人自扰
    2021-02-04 11:12

    A step-wise solution is provided below:

    1. Go to the folder where you have placed your flask app (on the command line)

    2. Create a virtual environment as using the command ($ py -m venv env) here 'venv' is the short form of the virtual environment and 'env' at the end represents the name of the environment which you want (I have named it as env). Thereafter you can see at from the file explorer that a folder named 'env' is created in the folder stated at point #1 above.

    3. Enter the following command ($env\Scripts\activate) by pressing enter this will turn on your virtual environment

    4. Thereafter, enter the following command ($set FLASK_APP=.py)

    5. Enter the following command ($flask run)

提交回复
热议问题