Coder Social home page Coder Social logo

qpc-database / python-sample-vscode-flask-tutorial Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/python-sample-vscode-flask-tutorial

1.0 1.0 0.0 55 KB

Sample code for the Flask tutorial in the VS Code documentation

Home Page: https://code.visualstudio.com/docs/python/tutorial-flask

License: MIT License

Python 29.20% CSS 10.35% HTML 34.17% Dockerfile 26.27%

python-sample-vscode-flask-tutorial's Introduction

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

python-sample-vscode-flask-tutorial's People

Contributors

dependabot[bot] avatar drasseltv avatar feyghub avatar halderex avatar hyunchel avatar jhamukesh998 avatar jlintusaari avatar kraigb avatar microsoftopensource avatar msftgits avatar richaagrawa avatar swedishmike avatar timpreble avatar tonybaloney avatar uchenkadicode avatar yashsahugtx avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.