推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
dirk41
V2EX  ›  Python

flask-socketio 怎么和 app 端通信啊

  •  1
     
  •   dirk41 · Nov 30, 2016 · 3435 views
    This topic created in 3475 days ago, the information mentioned may be changed or developed.

    写了个简单服务 socketio 服务,可以与 web 端通信,但是和 app 端就是没有办法通信, 是服务器的问题还是终端问题?请各位大神帮帮忙

    #!/usr/bin/env python

    -- coding: utf-8 --

    from flask import Flask, render_template from flask_socketio import SocketIO, send from flask_sqlalchemy import SQLAlchemy app = Flask(name) app.config['SECRET_KEY'] = 'mysecret' socketio = SocketIO(app) @socketio.on('message') def handleMessage(msg): print 'Message:' + msg send(msg, broadcast=True) if name == 'main': socketio.run(app, host= '0.0.0.0', port=5008, debug=True)

    5 replies    2016-11-30 21:16:32 +08:00
    wwqgtxx
        1
    wwqgtxx  
       Nov 30, 2016 via iPhone
    和 app 请使用 socket.io 的客户端进行通讯
    dirk41
        2
    dirk41  
    OP
       Nov 30, 2016
    @wwqgtxx, 我想用 python 做服务器端, 然后 app 作为客户端? 您说的是 python 这边也用客户端?
    wwqgtxx
        3
    wwqgtxx  
       Nov 30, 2016 via iPhone
    @dirk41 是的, socket.io 并不是标准 socket 协议,所以必须要用专门的客户端通讯
    dirk41
        4
    dirk41  
    OP
       Nov 30, 2016
    @wwqgtxx 那服务器端呢, 不使用还是使用其他什么?
    wwqgtxx
        5
    wwqgtxx  
       Nov 30, 2016
    @dirk41 你的服务端是 flask-socketio ,客户端也要用符合 socket.io 标准协议的客户端,这样好理解了吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2249 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 00:46 · PVG 08:46 · LAX 17:46 · JFK 20:46
    ♥ Do have faith in what you're doing.