推荐学习书目
› 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
playniuniu
V2EX  ›  Python

请问使用 Flask 时同时监听其他 Socket,应该怎么做?

  •  
  •   playniuniu · Feb 14, 2016 · 5386 views
    This topic created in 3879 days ago, the information mentioned may be changed or developed.
    有这么一个需求,数据需要监听 Socket 传过来,并吐给 Webserver ,我想使用 Flask 当 Webserver ,请问能在一个进程中,同时开启 Flask ,并监听 Socket 上的数据嘛?

    如果可以的话,代码应该怎么写呢, Socket 和 Flask 之间的数据怎么互通?

    求助
    2 replies  •  2016-02-14 11:46:56 +08:00
    fburst
        1
    fburst  
       Feb 14, 2016
    Flask is a microframework for Python 。
    框架不是 server 。
    Flask 带的 server 很弱。
    9hills
        2
    9hills  
       Feb 14, 2016
    Flask 没有带 Server ,用的是 Werkzeug 这个 wsgi 实现,后者自带了一个简单的 server ,基于 BaseHTTPServer.HTTPServer

    你这个问题和 Flask 没关系,你启动一个 SocketServer 就好了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5029 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 65ms · UTC 09:01 · PVG 17:01 · LAX 02:01 · JFK 05:01
    ♥ Do have faith in what you're doing.