Im trying to use wsgi form tornado, coz the server accept only wsgi.
I've tried all variant of servers for tornado + wsgi, always getting this error: __call__() takes 2 positional arguments but 3 were given
# app/__init__.py
import tornado.wsgi
import tornado.web
import wsgiref.simple_server
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.render("templates/index.html")
def routes():
return [
(r"/", MainHandler),
]
class Application(tornado.wsgi.WSGIContainer):
def __init__(self):
handlers = routes()
tornado.wsgi.WSGIContainer.__init__(self, handlers)
# wsgi.py
import wsgiref.simple_server
from app import Application
application = Application()
server = wsgiref.simple_server.make_server('', 8888, Application())
server.serve_forever()
Here is error trace:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
TypeError: __call__() takes 2 positional arguments but 3 were given
127.0.0.1 - - [10/Aug/2019 17:40:58] "GET / HTTP/1.1" 500 59
I expecte working tornado.wsgi, any help will be useful!
WSGIContainer
goes the other direction: it lets you run wsgi apps on Tornado's HTTP server, not run tornado apps on a WSGI server.
In Tornado 5.1, you could do this with WSGIAdapter. In Tornado 6.0, WSGIAdapter
is gone and there is no longer any way to run Tornado applications on a WSGI server; you must use Tornado's server.