File: flaskapp_aiohttp_wsgi.py

package info (click to toggle)
gunicorn 20.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,088 kB
  • sloc: python: 9,219; makefile: 161; xml: 73; sh: 40; javascript: 35
file content (24 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Example command to run the example:
#
#   $ gunicorn flaskapp_aiohttp_wsgi:aioapp -k aiohttp.worker.GunicornWebWorker
#

from aiohttp import web
from aiohttp_wsgi import WSGIHandler
from flask import Flask

app = Flask(__name__)


@app.route('/')
def hello():
    return 'Hello, world!'


def make_aiohttp_app(app):
    wsgi_handler = WSGIHandler(app)
    aioapp = web.Application()
    aioapp.router.add_route('*', '/{path_info:.*}', wsgi_handler)
    return aioapp

aioapp = make_aiohttp_app(app)