Go back

Running Flask Demos

Note: Visual Studio Code is configured to use /home/coder as the project home folder. Any new files and folders during development must be created under /home/coder .

/img/common/python-django-flask-common-images/vscode-web-interface.png

Follow below steps to create and run the demos:

  • Make sure to create new Flask projects inside the /home/coder/ directory, so that your new projects will be available in the Browser based Visual Studio Code.

  • Once your project is created, navigate to your project directory where your app.py file exist.

  cd /home/coder/my_flask_app

/img/common/python-django-flask-common-images/cd-flask-directory-new.png

  • Then switch to the super user. This is required to run Flask server on port 80
  sudo su
  • Then set the FLASK_APP environment variable to the app file
  export FLASK_APP=app.py

/img/common/python-django-flask-common-images/export-flask-env.png

  • Then start the flask server by running below command
  flask run -h 0.0.0.0 -p 80

/img/common/python-django-flask-common-images/run-flask-server-new.png

  • After running the command, open http://publicip and you should see the demo page displayed. Make sure to use http and not https.

/img/common/python-django-flask-common-images/flask-demo.png

Go back