随笔分类 -  Flask

摘要:多app应用(了解) ### 多个app实例(启用) from werkzeug.wsgi import DispatcherMiddleware from werkzeug.serving import run_simple from flask import Flask, current_app 阅读全文
posted @ 2020-09-03 19:23 pythoner_wl 阅读(243) 评论(0) 推荐(0) 编辑
摘要:g 对象 g 是一个全局变量,存取自定义的变量 session对象是可以跨request的,只要session还未失效,不同的request的请求会获取到同一个session,但是g对象不是,g对象不需要管过期时间,请求一次g对象就改变了一次,或者重新赋值了一次 flask-session # 替换 阅读全文
posted @ 2020-09-03 19:19 pythoner_wl 阅读(333) 评论(0) 推荐(0) 编辑
摘要:中间件(跟django中间件完全不一样) from flask import Flask app = Flask(__name__) @app.route('/') def index(): return 'Hello World!' # 模拟中间件 class Md(object): def __ 阅读全文
posted @ 2020-08-27 19:29 pythoner_wl 阅读(173) 评论(0) 推荐(0) 编辑
摘要:路由支持正则 #1 写类,继承BaseConverter #2 注册:app.url_map.converters['regex'] = RegexConverter #3 使用:@app.route('/index/<regex("\d+"):nid>') 正则表达式会当作第二个参数传递到类中 f 阅读全文
posted @ 2020-08-26 19:56 pythoner_wl 阅读(161) 评论(0) 推荐(0) 编辑
摘要:flask 项目 from flask import Flask,request app=Flask(__name__) @app.route('/') def index(): print(request.path) return 'hello world' if __name__ == '__m 阅读全文
posted @ 2020-08-25 20:17 pythoner_wl 阅读(345) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示