[英]How to register the wsgi if the python-socketio is a part of my project
I am reading the python-socketio example . 我正在阅读python-socketio示例 。
in its wsgi.py
: 在其
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
: 在
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: 我想知道,GitHub示例显示了使用此方法注册wsgi应用程序:
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? 但是在我的项目中,
python-socketio
是其中的一部分,如何在这种情况下注册wsgi
?
I mean I want to make the python-socketio
application to be a part of my project, as a app
in project. 我的意思是我想使
python-socketio
应用程序成为项目的一部分,成为项目中的app
。 But I don't know how to configure the wsgi
. 但是我不知道如何配置
wsgi
。
EDIT-01 编辑01
My project wsgi.py
current code is bellow: 我的项目
wsgi.py
当前代码如下:
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. 在
wsgi.py
,像下面这样配置eventlet
,我解决了这个问题。
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.