最近搜索
暂无搜索记录
热搜
JAVA
大数据
分布式
Python
人工智能
爬虫
WEB
JavaScript
认证
from flask import Flask,request
app = Flask(__name__,static_url_path='/laoxiao',static_folder='static') #初始化flask项目服务
@app.route('/') #装饰器-路由
def hello_world():
return 'Hello World!'
@app.route('/test1.html', methods=['GET'])
def test1():
user_id = request.args.get('user_id')
print("用户id是:{}".format(user_id))
name = request.args.get('name')
print("用户的名字是:{}".format(name))
return "请求成功"
if __name__ == '__main__':
app.run(host='0.0.0.0',port=8080,debug=False) #在企业中设置为false
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试请求方式和请求参数</title>
<style>
.parent{
text-align: center;
}
</style>
</head>
<body>
<div class="parent">
<h2>请求方式</h2>
<a href="/test1?user_id=100&name=zhangsan">get请求</a>
<h5>post请求</h5>
<form action="" method="post">
<input type="text">
<input type="submit">
</form>
</div>
</body>
</html>