Running Flask with pycharm
Create a configuration. For the simple app you show, all you need to do is execute flaskapp.py
. Right click on flaskapp.py
and chose "Create 'flaskapp'". You can chose "Edit Configurations..." from the dropdown to the left of the run button to edit the configuration that's created.
With PyCharm Community Edition 2019 on Windows :
- Edit your configuration or Create a new configuration
- In "Script path" set the path to flask.exe (1)
- Set "Parameters" to run
- Add to "Environment variables"
- FLASK_APP=yourserverfile.py
- FLASK_ENV=development
Now you can run your app with Shift+F10 (Release) or Shift+F9 (Debug)
Open a web broswer and go to http:127.0.0.1:5000 (if your port is 5000, default port is 5000)
Below Screenshot of configuration
Notes :
(1) Flask.exe should be in the Scripts directory of the Python path, something like "C:\Users\YOUR_USERNAME\Local\Programs\Python\Python36-32\Scripts\flask.exe"