0

After creating a project with django, and auditing the code via chrome audit, it shows

Does not use HTTP/2 for all of its resources 2 requests not served via HTTP/2

to fix this error I followed this tutorial

https://medium.com/python-pandemonium/how-to-serve-http-2-using-python-5e5bbd1e7ff1

and when using the code specified for 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)

I get

/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 not yet supported".format(','.join(kwargs.keys())), Running on https://localhost:5000 (CTRL + C to quit) [2019-11-06 18:30:18,586] ASGI Framework Lifespan error, continuing without Lifespan support

and also I cant load the webpage via https://localhost:5000

Avin Mathew
  • 336
  • 11
  • 25

1 Answers1

2

ASGI Framework Lifespan error, continuing without Lifespan support

Is really just a warning, it notes that Django does not yet support the lifespan part of the ASGI specification. Which won't cause you any issues (given the snippet).

The article you've referenced is outdated, this is an updated version. To make it work for your your snippet just change the if statement to this (below) and it should work, (although the updated article shows a better way)

...

if __name__ == '__main__':
    app.run(
        host='localhost', port=5000, certfile='cert.pem', keyfile='key.pem'
    )
pgjones
  • 6,044
  • 1
  • 14
  • 12