Create and deploy Flask apps in PTVS

What is Flask

Flask is a micro web development framework for Python. It relies on the Jinja2 template engine and the Werkzeug WSGI toolkit.

Flask app development with Python Tools 2.2 for Visual Studio

1. Start Visual Studio

[New project] ▶ ︎ [Python / Web] ▶ ︎ [Flask Web Projet] Select to create a project 1.png

2. RUN the created project

2.png 3.png

3. Create new HTML

[Project] ▶ ︎ [template] ▶ ︎ [Right click / Add] Create empty HTML with 4HTML作成.png

4. Fill in the code in the empty HTML

test.html


<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Hello</title>
</head>
<body>
    Hello World
</body>
</html>

Comment out home () in view.py and write it to load the new test.html (newly created HTML).

view.py


def home():
    return render_template('test.html')

"""
def home():
    return render_template(
        'index.html',
        title='Home Page',
        year=datetime.now().year,
    )
"""

5. When executed, Hello World is displayed

5表示.png

6. Deploy

[Project / Right click] ▶ ︎ [Public] 6公開.png

7.png 8.png

Decide a new arbitrary name in the Web App name and App Service plan items 9.png

Check here only! Issued unless otherwise changed 10.png

Finally, check the app created on Azure. [App Service] ▶ ︎ [APP name] ▶ ︎ [Overview] Click the URL to open it! 11.png

Recommended Posts

Create and deploy Flask apps in PTVS
Create initial settings and staff apps in Django
Create a CSV reader in Flask
Create and read messagepacks in Python
Create and deploy a Django (PTVS) app using Azure Table storage
Create and run embulk config in Jupyter
Create Amazon Linux with AWS EC2 and log in
Change static file storage directories and URLs in Flask
Daemonize and persist Python web apps in Systemd-Ubuntu 18.04.3 LTS
Create SpatiaLite in Python
Image uploader in Flask
Get and create nodes added and updated in the new version
[Azure] Create, deploy, and relearn a model [ML Studio classic]
Create code that outputs "A and pretending B" in python
Create an authentication feature with django-allauth and CustomUser in Django
Create a deploy script with fabric and cuisine and reuse it
How to create dataframes and mess with elements in pandas
Create Cognito user list in S3 with SQS Deploy queue function and API to Lambda with SAM