Learning Website: flask-github-net-cn (non-mp.weixin.qq.com domains cannot be inserted, the short link needs to be changed to a dot)
English Website: flask-palletsprojects-com/en/stable
Create an Environment
> mkdir myproject
> cd myproject
> py -3 -m venv .venv
Activate the Environment
> .venv\Scripts\activate
Install Flask
$ pip install Flask
A Minimal Application
from flask import Flask
app = Flask(__name__)
@app.route(“/”)
def hello_world():
return “<p>Hello, World!</p>”
$ flask –app hello run
* Serving Flask app ‘hello’
* Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
If the port is occupied flask –app app run –port 5003
Python‘s startup method
if __name__ == “__main__”:
app.run(debug=True)
$ python hello.py
In VS Code,Ctrl+Shift+P (on macOS it’s Cmd+Shift+P) is the shortcut to open the Command Palette.
The Role of the Command Palette
The Command Palette is a very core and powerful feature in VS Code, allowing you to:
· Execute almost all available VS Code commands: including file operations, settings changes, debugging commands, extensions, etc., without needing to go through the menu or remember specific shortcuts.
· Quickly access Settings (Settings): usually type settings.
· Quickly install and manage extensions (Extensions): usually type install extension or extension.
· Switch workspaces or files: although there are dedicated shortcuts, it can also be done in the command palette.
When you press Ctrl+Shift+P, a search box will pop up, and you just need to enter the keyword of the command you want to execute (for example, Format Document, Open Settings, Toggle Word Wrap), and it will filter matching commands in real-time, press Enter to execute.