Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sample code for the Flask tutorial in the VS Code documentation

License

NotificationsYou must be signed in to change notification settings

microsoft/python-sample-vscode-flask-tutorial

Repository files navigation

  • 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 theDockerfile anduwsgi.ini files necessary to build a container with a production server. The resulting image works both locally and when deployed to Azure App Service. SeeDeploy Python using Docker containers.

  • To run the app locally:

    1. Run the commandcd hello_app, to change into the folder that contains the Flask app.
    2. Run the commandset FLASK_APP=webapp (Windows cmd) orFLASK_APP=webapp (macOS/Linux) to point to the app module.
    3. Start the Flask server withflask run.

The startup.py file

In the root folder, thestartup.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 ownmodule in thehello_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.

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

Contributing

Contributions to the sample are welcome. When submitting changes, also consider submitting matching changes to the tutorial, the source file for which istutorial-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, visithttps://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

About

Sample code for the Flask tutorial in the VS Code documentation

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors18


[8]ページ先頭

©2009-2025 Movatter.jp