实例
import time
from flask import Flask
from flask_common import Common
app = Flask(__name__)
app.debug = True
common = Common(app)
# 缓存view到内存
@app.route("/")
@common.cache.cached(timeout=50)
def hello():
time.sleep(1)
return "Hello World!"
if __name__ == "__main__":
common.serve()
特性:
/favicon.ico
重定向到/static/favicon.ico
WEB_CONCURRENCY
环境变量定义gunicorn workers的数量PORT
环境变量定义端口配置
app.config['COMMON_FILESERVER_DISABLED'] = 1
app.config['COMMON_POWERED_BY_DISABLED'] = 1
app.config['COMMON_PROCESSED_TIME_DISABLED'] = 1
app.config['COMMON_CACHE_TYPE'] = "simple"