使用 django 创建项目,并通过 chrome audit 审核代码后,它显示
不对所有资源使用 HTTP/2 2 个请求未通过 HTTP/2 提供服务
为了解决这个错误,我遵循了这个教程
https://medium.com/python-pandemonium/how-to-serve-http-2-using-python-5e5bbd1e7ff1
以及使用为 quart 指定的代码时
import ssl
from quart import make_response, Quart, render_template, url_for
app = Quart(__name__)
@app.route('/')
async def index():
result = await render_template('index.html')
response = await make_response(result)
response.push_promises.update([
url_for('static', filename='css/bootstrap.min.css'),
url_for('static', filename='js/bootstrap.min.js'),
url_for('static', filename='js/jquery.min.js'),
])
return response
if __name__ == '__main__':
ssl_context = ssl.create_default_context(
ssl.Purpose.CLIENT_AUTH,
)
ssl_context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
ssl_context.set_ciphers('ECDHE+AESGCM')
ssl_context.load_cert_chain(
certfile='cert.pem', keyfile='key.pem',
)
ssl_context.set_alpn_protocols(['h2', 'http/1.1'])
app.run(host='localhost', port=5000, ssl=ssl_context)
我明白了
/home/avin/Documents/projects/portfolio/portfolio_env/lib/python3.6/site-packages/quart/app.py:1320: UserWarning: Additional arguments, ssl, are not yet supported
“Additional arguments, {}, are尚不支持".format(','.join(kwargs.keys())),在 https://localhost:5000上运行(CTRL + C 退出)[2019-11-06 18:30:18,586] ASGI框架生命周期错误,在没有生命周期支持的情况下继续
而且我也无法通过https://localhost:5000加载网页