[PYTHON] (For myself) Put Flask in VS Code

Let's put Flask in VS Code and cry (macOS)

I don't really understand what Flask is

1. First only the flow

  1. Create a virtual environment with venv
  2. Insert Flask with pip install
  3. Check the operation and finish

2. Specific story

2-1. Create a virtual environment

--Create a nice folder

--python3 -m venv <name of virtual environment> Put it in the terminal of the created folder (If you get angry, try changing py, python, python3 by brute force)

--Maybe there is python ~~ in the lower left, so select that,
There should be something like "Python ", so click it.
It's like declaring that you're going to use a Python virtual environment

--If you want to use the terminal in a virtual environment, you can find it on the toolbar above. "View"-> "Command Palette"-> "Enter Python: Create Terminal "
Open with

2-2. Installing Flask

--Open a terminal as described above and enter pip install flask

--You can check the modules included with pip freeze, it is better to see if they are included properly

2-3. A little operation check

Display something * text * and check if it works

--Put the code below and save ("command + s ne")

from flask import Flask
app = Flask(__name__)

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

When a link in "" is requested by @ app.route ("/ "), it returns the behavior of the function below. You shouldn't think about the above two lines yet

--Open the terminal as above and open the terminal

$ export FLASK_APP=app.py
$ flask run

I put it in.

--A link called port 5000 on the local host will be displayed on the terminal, so try moving to it. It's okay if * Hello World * is displayed properly

――It's said that there is no Flask module, but you should think about it. You can do it.

3. End

――Let's take another opportunity to see if it works automatically with debugging. ――I wonder if it is better to make the web_app that rides on the server from the front end or the back end.

Recommended Posts

(For myself) Put Flask in VS Code
VS Code settings for developing in Python with completion
Expose settings.json for efficient Python coding in VS Code
(For myself) Flask_8 (Add / Edit / Delete in database with python)
VS Code snippets for data analysts
(For myself) Flask_7 (Open database from Flask)
Create a Python environment for professionals in VS Code on Windows
(For myself) Flask_5 (Add to txt file)
Pass PYTHONPATH in 1 minute with VS Code
Tips for building large applications in Flask
AtCoder cheat sheet in python (for myself)
Code required for API conversion in sqlalchemy
(For myself) Flask_3 (form, POST and GET)
Generate QR code in Python
[Python] Generate QR code in memory
Fourier series verification code written in Python
(For myself) Put Flask in VS Code
Code required for API conversion in sqlalchemy
I tried Flask with Remote-Containers of VS Code
(For myself) AWS_Flask_3 (Install / Run Flask on AWS)
Use Python in Anaconda environment with VS Code
Settings for Python coding in Visual Studio Code
Set up TinyGo development environment for VS Code
Add auto-completion to EV3 Micropyhon programming in VS Code
Specific sample code for working with SQLite3 in Python
Allow real-time code checking in Python development with VS Code
VS Code says there is an error in cv2
Revive symbol search in Python workspace with VS Code
Enable intellisense for external libraries with Pipenv + VS Code
Python code for k-means method in super simple case
(For myself) Flask_2 (list and for, extends, and a little more)
Put matplotlib in Centos7.
Put scipy in ec2
Put jedi in emacs 24
Techniques for code testing?
[Visual Studio Code] [Python] [Windows] Support for garbled Japanese characters in Python in VS Code task / debug output
Put pip in Blender
heroku memo (for myself)
Image uploader in Flask
Freecad memorandum (for myself)
Insert Import statements needed for Python code completion in Neovim
Tutorial for doing Test Driven Development (TDD) in Flask-2 Decorators
Test code to check for broken links in the page
How to use VS Code in venv environment on windows
(For myself) Flask_6 (Open db from python, Mysql basic (phpMyAdmin))
(For myself) Flask_4 (Drop-down menu, view txt data (using table))
Tutorial for doing Test Driven Development (TDD) in Flask ―― 1 Test Client
Comfortable LaTeX with Windows Subsystem for Linux and VS Code
Reference reference for those who want to code in Rhinoceros / Grasshopper
UpNext2 Development Record # 1 Build Python CI environment in VS Code
I want to be able to run Python in VS Code