Search code examples
pythonwindowsflaskvisual-studio-codeapi-key

How do I set an API_KEY in Windows terminal?


I'm having trouble running my flask based web app that uses an api key from IEX. Normally in my Linux based cloud IDE I run:

export API_KEY=[keyhere]

in the command line and the program works fine. But I cannot get my program to run locally in my Windows machine. When I run the exact same command in the terminal it says:

'export' is not recognized as an internal or external command, operable program or batch file.

I've found a quirk about the Windows terminal compared to linux from a different necessary command. In Linux I may write:

FLASK_APP=application.py

but in Windows I am supposed to write the same as:

$env:FLASK_APP='application.py'.

Writing $env: for the API_KEY command results in this error though:

The filename, directory name, or volume label syntax is incorrect.

I'm using VSCode if that helps. I tried setting the API_KEY in both the VSCode's integrated terminal and Window's operating system terminal. Does anyone know how to set an API_KEY in Windows?


Solution

  • In Windows the command is set as compared to export in Linux/Unix based systems.