1 Star 0 Fork 0

王麒嘉/pythonFlaskProject

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.py 981 Bytes
一键复制 编辑 原始数据 按行查看 历史
王麒嘉 提交于 2024-11-20 14:25 +08:00 . 1113
from flask import Flask, render_template, jsonify, make_response, url_for, redirect
app = Flask(__name__)
@app.route('/')
def hello_world(): # put application's code here
user1 = {'name' :'john', 'age' : 20}
user2 = {'name' :'jane', 'age' : 30}
list_users = [user1, user2]
res = make_response(jsonify(list_users),202)
return res
@app.route('/hello')
def hello(): # put application's code here
user1 = {'name' :'john', 'age' : 20}
user2 = {'name' :'jane', 'age' : 30}
user3 = {'name': 'jane', 'age': 30}
list_users = [user1, user2,user3]
res = make_response(jsonify(list_users),202)
return res
@app.route('/main/<num>')
def main(num): # put application's code here
return render_template('index.html',num = num)
@app.route('/hello/flask')
def greet():
# return f"{url_for('greet')}" # 反向解析视图函数greet()对应的URL
return redirect(url_for("hello"))
if __name__ == '__main__':
app.run()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/laili26/python-flask-project.git
git@gitee.com:laili26/python-flask-project.git
laili26
python-flask-project
pythonFlaskProject
master

搜索帮助