文章分类 -  flask

摘要:1,redirect from flask import redirect @app.route('/') def hello_itcast(): return redirect('http://www.itcast.cn') 2,redirect_to from flask import Flas 阅读全文
posted @ 2021-12-13 21:15 下个ID见 阅读(3) 评论(0) 推荐(0)
摘要:正则URL是为了匹配指定的URL,而匹配指定的URL则可以达到限制访问,以及优化访问路径的目的。 from flask import Flask from werkzeug.routing import BaseConverter class Regex_url(BaseConverter): de 阅读全文
posted @ 2021-12-13 21:02 下个ID见 阅读(60) 评论(0) 推荐(0)
摘要:@app.route('/index/<int:nid>', methods=["GET", "POST"]) def hello_world(nid): print(nid, type(nid)) return 'Hello World!' # 11 <class 'int'> # Not Fou 阅读全文
posted @ 2021-12-12 22:27 下个ID见 阅读(21) 评论(0) 推荐(0)
摘要:1,添加路由 # 导入Flask类 from flask import Flask #Flask类接收一个参数__name__ app = Flask(__name__) # 装饰器的作用是将路由映射到视图函数index @app.route('/') def index(): return 'He 阅读全文
posted @ 2021-12-04 23:08 下个ID见 阅读(138) 评论(0) 推荐(0)
摘要:底层处理原理 Django,传统的传参梳理模式 """view.py""" def index(rquest): return HttpResponse("Hello World!") flask,上下文管理 @app.route('/') def hello_world(): return 'He 阅读全文
posted @ 2021-11-18 23:28 下个ID见 阅读(75) 评论(0) 推荐(0)
摘要:1,普通的装饰器 装饰器的本质就是闭包,在不改变原来函数的基础上,拓展一个新功能。 闭包的特点:可以延长局部变量的生命周期 def outer(func): def inner(*args,**kwargs): res = func(*args,**kwargs) return res return 阅读全文
posted @ 2021-11-17 00:31 下个ID见 阅读(132) 评论(1) 推荐(0)