bottleGET的基本原理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from bottle import route,run,request
#通过包含在url中的参数获取用户输入
htmlst = """
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title><h2>你好</h2></title>
<h2>你好</h2>
</head>
<body>
<form action="/info" method='GET'>
<a href="http://localhost/info?id=437221368&email=437221368@qq.com">提交GET信息</a>
</form >
</body>
</html>
"""


@route('/')
def index():
return htmlst


@route('/info',method='GET')#默认也是GET
def gepinfo():
id = request.query.id #get到的信息,返回空字符串的时候不会让服务器崩溃
email = request.query.email #get到的信息
return (id,email)


run(port=8088,debug=True,reloader=True)

转载请注明来源 https://tianweiye.github.io