Quickstart
On PowerShell
1
2
3
4
5
6mkdir flk
cd flk
py -m venv venv
pip install flask
mk hello.py
New-Item hello.py -type file在 hello.py 写入
1
2
3
4
5
6from flask import Flask
app = Flask(__name__)
def hello_world():
return 'Hello, World!'run
1
2$env:FLASK_APP = "hello.py"
flask runget / post
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def hello_world():
return 'Hello, World!'
def elias():
return 'Hello, elias!'
def elias(username):
return 'Hello, %s!' % username
# @app.route('/name/<float:a>') #float
def elias(a):
return 'Hello, %s!' % (a + a)
def login():
if request.method == 'POST':
return "A"
else:
return "B"