Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use websockets in Flask and Python 3?

I see that Flask-SocketIO only supports Python 2.x for now. Is there a way of using WebSockets (ideally within Flask) on Python3?

like image 787
Paul Avatar asked Mar 19 '15 00:03

Paul


People also ask

Does flask support WebSockets?

Flask, being a minimalist web framework, does not have WebSocket support built-in. The old Flask-Sockets extension, which has not been maintained in the last few years, provided support for this protocol.

Does Python support WebSockets?

websockets is a library for building WebSocket servers and clients in Python with a focus on correctness, simplicity, robustness, and performance. Built on top of asyncio , Python's standard asynchronous I/O framework, it provides an elegant coroutine-based API.

Which language is best for WebSockets?

A WebSocket server can be written in any server-side programming language that is capable of Berkeley sockets, such as C(++), Python, PHP, or server-side JavaScript.


1 Answers

Now you can. Miguel's FlaskIO extension supports Python 3 since 1.0 as announced on his blog. Make sure to check PyPI in order to install one of the recent versions. At the time of writing, the last release is:

pip install flask-socketio==1.2
like image 67
CESCO Avatar answered Oct 07 '22 01:10

CESCO