在此代码中插入HTTP的最佳方法是什么? 我需要使用Bootlepy和Gevent,就像这个例子一样。 感谢
from gevent import monkey; monkey.patch_all()
from time import sleep
from bottle import route, run
@route('/hello')
def hello():
return "<html><body>hello</body></html>"
@route('/stream')
def stream():
yield 'START'
sleep(3)
yield 'MIDDLE'
sleep(5)
yield 'END'
run(host='0.0.0.0', port=8080, server='gevent')
答案 0 :(得分:0)
from gevent import pywsgi
import bottle
# Get bottle's WSGI callable
wsgi_app = bottle.default_app()
# Needs a generated SSL key and certificate to use.
server = pywsgi.WSGIServer(('0.0.0.0', 443), wsgi_app,
keyfile='server.key', certfile='server.crt')
server.serve_forever()