Web application created with Python + Flask (using VScode) # 1-Virtual environment construction-

background

Even if you can study what is called AI technology such as DL and ML and implement it by programming, if you try to spread it within the company, a coding barrier will occur and it will not spread easily.

Purpose

Even if you say "Put a Jupyter notebook and use python to remember" in the department, it takes time to learn for people who do not usually handle programming at work, so if you read the data as a Web application and click it, you can move it! I wish I could make a UI that says, so I started studying. I would like to keep the knowledge I gained.

means

This time, create it using VScode + Flask. First, create a simple web page.

environment

This time, we will proceed with the miniconda 4.7.12 installed on Windows 10. It does not use the conda virtual environment. 3.7.3 is installed for python.

procedure

Start command palette (Ctrl + Shift + P) → Enter interpreter. The created environment selection.   image.png OK if the workspace name and environment name are displayed in the lower left window  image.png

Reboot the terminal to activate the virtual environment.  image.png

The environment switches.  image.png

Create an a.py file as a trial ⇒ The Linter pylint Install screen appears. When installed, it will check the syntax.  image.png  image.png

Install the required libraries Install Flask this time (install any missing items)  image.png

app.py


from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello_world():
  return "Hello, World!"

You will be asked for F5 ⇒ debug configuration in VS code, so select Flask and execute image.png image.png

app.py will be executed. If you click the URL of Running on http: // ... and Hello! World! Is displayed in your browser, it is successful.

By the way, the configuration is described in the launch.json file in the .vscode folder. image.png

By changing this code, you can set the py file to operate, host, port, etc. For example, when accessing from another PC in the LAN, add host and port.

launch.json


{

    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "app.py", #Specify the py file to start
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "0"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload",
                "--host=0.0.0.0", #Postscript
                "--port=5000", #Postscript
            ],
            "jinja": true
        }
    ]
}

By describing as above, you can access by entering the IP address or computer name of the PC running Flask into the browser.

Recommended Posts

Web application created with Python + Flask (using VScode) # 1-Virtual environment construction-
Web application with Python + Flask ② ③
Web application with Python + Flask ④
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
Web application made with Python3.4 + Django (Part.1 Environment construction)
WEB application development using django-Development environment construction-
Virtual environment with Python 3.6
From Python environment construction to virtual environment construction with anaconda
Create a Python3.4 + Nginx + uWSGI + Flask Web application execution environment with haste using pyenv on Ubuntu 12.04
Web application development with Flask
Parse and visualize JSON (Web application ⑤ with Python + Flask)
QGIS3 Python plugin development environment construction with VSCode (macOS)
Create a web application execution environment of Python3.4 + Nginx + uWSGI + Flask with haste using venv on Ubuntu 14.04 LTS
[SAP CP] Web API created with python in CF environment
Get started with Python! ~ ① Environment construction ~
Creating a web application using Flask ②
Build python virtual environment with virtualenv
Create a virtual environment with Python!
Building a virtual environment with Python 3
Creating a web application using Flask ①
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
Using Chainer with CentOS7 [Environment construction]
Creating a web application using Flask ③
pytorch @ python3.8 environment construction with pipenv
Creating a web application using Flask ④
Application development with Docker + Python + Flask
Python3.6 environment construction (using Win environment Anaconda)
Python x Flask x PyTorch Easy construction of number recognition web application
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Try using the web application framework Flask
Vue.js + Flask environment construction memorandum ~ with Anaconda3 ~
[Python] Create a virtual environment with Anaconda
Python3 + venv + VSCode + macOS development environment construction
VScode environment construction (Windows10, Python, C ++, C, Git)
[Python] A quick web application with Bottle!
Easy web app with Python + Flask + Heroku
Run a Python web application with Docker
Build a python virtual environment with pyenv
[Python] Web application from 0! Hands-on (0) -Environmental construction-
Add a Python virtual environment to VSCode
Let's get along with Python # 0 (Environment construction)
Comfortable Jupyter Lab (Python) analysis environment created with Docker + VSCode + Remote Container
Environment construction of Flask / MySql / Apache / mod_wsgi / virtualenv with Redhat7 (Python2.7) November 2020
[GCP] Procedure for creating a web application with Cloud Functions (Python + Flask)
Automatic posting of web design gary site with python + selenium (1) Environment construction
I want to make a web application using React and Python flask
Easy-to-understand explanation of Python Web application (Django) even for beginners (1) [Environment construction]
Implement a simple application with Python full scratch without using a web framework.
Python environment construction
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
Collecting information from Twitter with Python (Environment construction)
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
Vienna with Python + Flask web app on Jenkins
Python (Windows 10) Virtual Environment / Package with VS Code
Create a virtual environment with conda in Python
Try using conda virtual environment with Jupyter Notebook
Installation of Python3 and Flask [Environment construction summary]