简体   繁体   中英

How to set environment variables in git bash?

I use windows and I'm trying to run flask through Git Bash and ConEmu. I entered the following commands:

set FLASK_APP=application.py
set FLASK_DEBUG=1
set DATABASE_URL=postgres://someurl
flask run

and this was the result:

* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

Do I need to write the commands directly into the bash file?

EDIT: I tried setting the variables in bash_profile, but that did not change the results I got. (I did remember to restart my terminal.)

You can set it locally for the command:

FLASK_APP=application.py FLASK_DEBUG=1 DATABASE_URL=postgres://someurl flask run

Or you can set it permanently for the session:

export FLASK_APP=application.py
export FLASK_DEBUG=1 
export DATABASE_URL=postgres://someurl 
flask run

The point is: there is no set var=value in git bash as you would use in a CMD. set , in bash, has another meaning .

Change the value of a shell option and set the positional parameters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM