I am reading the python-socketio example .
in its wsgi.py
:
import os
from django.core.wsgi import get_wsgi_application
from socketio import Middleware
from socketio_app.views import sio
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_example.settings")
django_app = get_wsgi_application()
application = Middleware(sio, django_app)
in the views.py
:
async_mode = None
import os
from django.http import HttpResponse
import socketio
basedir = os.path.dirname(os.path.realpath(__file__))
sio = socketio.Server(async_mode=async_mode)
thread = None
I want to know, the GitHub example shows use this method to register wsgi application:
django_app = get_wsgi_application()
application = Middleware(sio, django_app)
But in my project, the python-socketio
is a part of it, how can I register the wsgi
in this scenario?
I mean I want to make the python-socketio
application to be a part of my project, as a app
in project. But I don't know how to configure the wsgi
.
EDIT-01
My project wsgi.py
current code is bellow:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Qiyun02.settings")
application = get_wsgi_application()
Finally, I figure out the way to configure it:
in the wsgi.py
, configure the eventlet
like bellow, I solve this issue.
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Qyun.settings")
from socketio import Middleware
from website_chat.views import sio
django_app = get_wsgi_application()
application = Middleware(sio, django_app)
import eventlet
import eventlet.wsgi
eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.