python
def app(environ, start_response):
data = b"Hello, World!
"
start_response("200 OK", [
("Content-Type", "text/plain"),
("Content-Length", str(len(data)))
])
return iter([data])
if __name__ == "__main__":
from gunicorn.app.base import BaseApplication
class GunicornApp(BaseApplication):
def __init__(self, app, options=None):
self.options = options or {}
self.application = app
super().__init__()
def load_config(self):
for key, value in self.options.items():
self.cfg.set(key, value)
def load(self):
return self.application
options = {
"bind": "127.0.0.1:8000",
"workers": 4,
}
GunicornApp(app, options).run()
pip install gunicorn
pip install gevent
bind = "127.0.0.1:8000"
workers = 4
worker_class = "gevent"
worker_connections = 1000
timeout = 60
gunicorn app:app -c gunicorn.conf