[英]flask socket io not working ( windows 7 & 10 ) anaconda and python 3.7
I'm still a newbie in Development ( please don't rate down my post i've reached out everywhere to find a solution for the past 5 days ) , I had only two projects as a tutorial in the second project i had to use Socket IO with flask but its not working - if my code doesnt have socket io in it and i ran flask run
it output the following :我仍然是开发领域的新手(请不要评价我过去 5 天到处寻找解决方案的帖子),我只有两个项目作为我必须使用的第二个项目的教程带烧瓶的套接字 IO 但它不工作 - 如果我的代码中没有套接字 io 并且我运行
flask run
它输出以下内容:
D:\WORK\study sc5\project1\project1>flask run
Serving Flask app "hello"
Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
if it has socket io in it :如果它有套接字 io :
D:\WORK\study sc5\project2\project2>flask run
* Serving Flask-SocketIO app "application"
**when i visited 127.0.0.1:5000 i found the server running so i ignored that it doesn't print Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
and kept going tell i made the first test to see if socket io can print and i have noticed everything prints just fine but socket io **当我访问 127.0.0.1:5000 时,我发现服务器正在运行,所以我忽略了它不会打印
Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
并继续告诉我做了第一个测试,看看 socket io 是否可以打印,我注意到一切都打印得很好,但是 socket io
I've asked my class mates , made ticket on github for 5 days we couldn't solve this and i have tried on 2 machines ( home windows 10 and work place windows 7 ) both resulting the same thing我问过我的同学,在 github 上做了 5 天的票,我们无法解决这个问题,我已经在 2 台机器(Windows 10 和工作区 Windows 7)上尝试过,结果都是一样的
i made 2 videos about it ( i'll try to share them here if i'm allowed )我制作了 2 个关于它的视频(如果允许,我会尝试在这里分享它们)
the .py files only have the following .py 文件只有以下内容
import os
from flask import Flask
from flask_socketio import SocketIO, emit
app = Flask(__name__)
app.config["SECRET_KEY"] = "sdfsdfssefe"
socketio = SocketIO(app)
@app.route("/")
def index():
return "Project 2: TODO"
systems i have this with 1- windows 10 - anacanda 2- windows 7 - anacanda系统我有这个 1-windows 10-anacanda 2-windows 7-anacanda
things i have tried so far :到目前为止我尝试过的事情:
installing all required to run project 1安装运行项目 1 所需的一切
import os , passlib,requests导入操作系统,passlib,请求
from flask import Flask, session , render_template , request from from flask import Flask, session , render_template , request from
flask_session import Session from sqlalchemy import create_engine flask_session 导入会话来自 sqlalchemy 导入 create_engine
from sqlalchemy.orm import scoped_session, sessionmaker from从 sqlalchemy.orm 导入 scoped_session, sessionmaker from
passlib.hash import sha256_crypt passlib.hash 导入 sha256_crypt
instaling eventlet with python 3.7使用 python 3.7 安装 eventlet
results all the same except结果都一样,除了
now after cgywin and python 3.7 when i tried to run my own version of project 2 which used to run smoothly but doesn't print anything from socket io - it now says ( can't import application.py )
现在在 cgywin 和 python 3.7 之后,当我尝试运行我自己的项目 2 版本时,该版本过去运行平稳但不从 socket io 打印任何内容 - 现在显示(无法导入 application.py)
pip freeze点冻结
I've open ticket on course group , github and videos to demonstrate what happens if anyone could explain how i can upload them i will do edit the post and share them我已经在课程组、github 和视频上打开了票证,以演示如果有人可以解释我如何上传它们会发生什么我会编辑帖子并分享它们
https://github.com/miguelgrinberg/Flask-SocketIO/issues/807 ( i've also posted videos in the latest comments ) https://github.com/miguelgrinberg/Flask-SocketIO/issues/807 (我还在最新评论中发布了视频)
Does this work better?这样效果更好吗?
import os
from flask import Flask
from flask_socketio import SocketIO, emit
@app.route("/")
def index():
return "Project 2: TODO"
app = Flask(__name__)
app.config["SECRET_KEY"] = "sdfsdfssefe"
socketio = SocketIO(app)
if __name__ == '__main__':
socketio.run(app)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.