摘要:
1.上下文管理流程 流程图 # coding=utf8 """ threading.local 上下文管理 """ from flask import Flask, request, session app = Flask(__name__) app.__call__ @app.route("/in 阅读全文
摘要:
1.threading.local # coding=utf-8 import time from threading import local, Thread """ 每个线程都有一个唯一id 如何自己实现一个local呢? 通过一个字典 { id1: {val1:1}, id2: {val2:2 阅读全文
摘要:
1.目录结构 2.代码包 manage.py from src import app if __name__ == '__main__': app.run(debug=True) main.py from flask import Flask app = Flask(__name__) app.co 阅读全文
摘要:
1.中间件 # coding=utf-8 from flask import Flask app = Flask(__name__) app.config.from_object("settings.DevelopmentConfig") @app.route("/index", methods=[ 阅读全文
摘要:
1.闪现 # coding=utf-8 from flask import Flask, session, flash, get_flashed_messages app = Flask(__name__) app.config.from_object("settings.DevelopmentCo 阅读全文
摘要:
1.main.py # coding=utf-8 from flask import Flask, session app = Flask(__name__) # 请求执行之前 # before_request = [xxx, xxx1] @app.before_request def xxx(): 阅读全文
摘要:
1.简单使用 from flask import Flask, session app = Flask(__name__) app.secret_key = "adfas" app.__call__() @app.route("/index", methods=["POST", "GET"]) de 阅读全文
摘要:
1.main.py # coding=utf-8 from flask import Flask, render_template, Markup app = Flask(__name__) # 加上这个装饰器只有每个模板中都可以直接使用这个函数 {{ sb(1,2)}} @app.template 阅读全文
摘要:
1.请求 # coding=utf-8 import json from flask import Flask, redirect, render_template, request, jsonify, make_response app = Flask(__name__) @app.route(" 阅读全文
摘要:
##1.试图 # coding=utf-8 from flask import Flask, views from functools import wraps app = Flask(__name__) app.config.from_object("settings.DevelopmentCon 阅读全文
摘要:
1 from flask import Flask app = Flask(__name__) app.config.from_object("settings.DevelopmentConfig") @app.route("/index", methods=["POST", "GET"]) def 阅读全文
摘要:
1.简单配置倒入 # coding=utf-8 from flask import Flask app = Flask(__name__) # app.config.from_object("settings.DevelopmentConfig") @app.route("/index", meth 阅读全文
摘要:
1.简单flaskweb # coding=utf-8 from flask import Flask, render_template, request, redirect, session app = Flask(__name__, template_folder="templates") ap 阅读全文