Skip to content

Instantly share code, notes, and snippets.

@jordic
Created January 13, 2019 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordic/1caa31d1646a41e9ae73dc6cc7434fe1 to your computer and use it in GitHub Desktop.
Save jordic/1caa31d1646a41e9ae73dc6cc7434fe1 to your computer and use it in GitHub Desktop.
Zope on an aiohttp server
"""
This is just a proof of concept after reading this thread on waitress github issues
https://github.com/Pylons/waitress/issues/180
Running zope on an aiohttp app:
python3.7 -m venv zope4
source zope4/bin/activate
cd zope4
pip install Zope==4.0b8 -c https://zopefoundation.github.io/Zope/releases/4.0b8/constraints.txt
bin/mkwsgiinstance -d .
pip install aiohttp_wsgi
Add this file as app.py
python app.py
http://localhost:8080/hello -> helloworld
http://localhost:8080/manage -> ZMI
"""
from aiohttp import web
from aiohttp_wsgi import WSGIHandler
from Zope2.Startup.run import make_wsgi_app
app2 = make_wsgi_app({}, "./etc/wsgi.conf")
wsgi_handler = WSGIHandler(app2)
app = web.Application()
async def hello(request):
text = "Hello World"
return web.Response(text=text)
app.add_routes([web.get("/hello", hello)])
app.router.add_route("*", "/{path_info:.*}", wsgi_handler)
web.run_app(app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment