GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Navid-db/python-sample-vscode-flask-tutorial: Sample code for the Flask tutorial in the VS Code documentation

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

61 Commits
61 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
.github
.github
 
 
.vscode
.vscode
 
 
hello_app
hello_app
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
azure-pipelines.yml
azure-pipelines.yml
 
 
requirements.txt
requirements.txt
 
 
startup.py
startup.py
 
 
startup.txt
startup.txt
 
 
test_test1.py
test_test1.py
 
 
uwsgi.ini
uwsgi.ini
 
 

Repository files navigation

Python/Flask Tutorial for Visual Studio Code

  • This sample contains the completed program from the tutorial, make sure to visit the link: Using Flask in Visual Studio Code. Intermediate steps are not included.

  • It also contains the Dockerfile and uwsgi.ini files necessary to build a container with a production server. The resulting image works both locally and when deployed to Azure App Service. See Deploy Python using Docker containers.

  • To run the app locally:

    1. Run the command cd hello_app, to change into the folder that contains the Flask app.
    2. Run the command set FLASK_APP=webapp (Windows cmd) or FLASK_APP=webapp (macOS/Linux) to point to the app module.
    3. Start the Flask server with flask run.

The startup.py file

In the root folder, the startup.py file is specifically for deploying to Azure App Service on Linux without using a containerized version of the app (that is, deploying the code directly, not as a container).

Because the app code is in its own module in the hello_app folder (which has an __init__.py), trying to start the Gunicorn server within App Service on Linux produces an "Attempted relative import in non-package" error.

The startup.py file, therefore, is a shim to import the app object from the hello_app module, which then allows you to use startup:app in the Gunicorn command line (see startup.txt).

Contributing

Contributions to the sample are welcome. When submitting changes, also consider submitting matching changes to the tutorial, the source file for which is tutorial-flask.md.

Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot automatically determines whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

Additional details

  • This project has adopted the Microsoft Open Source Code of Conduct.
  • For more information see the Code of Conduct FAQ or
  • Contact [email protected] with any additional questions or comments.

About

Sample code for the Flask tutorial in the VS Code documentation

code.visualstudio.com/docs/python/tutorial-flask

Resources

Readme
License

Security policy

Security policy
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.