Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to run without Flask #54

Closed
iongion opened this issue Oct 23, 2016 · 3 comments
Closed

Is there a way to run without Flask #54

iongion opened this issue Oct 23, 2016 · 3 comments
Labels

Comments

@iongion
Copy link

iongion commented Oct 23, 2016

Is it really required to have Flask needed ? Did not find any way on how to avoid it, otherwise, awesome project!

@miguelgrinberg
Copy link
Owner

This project is not Flask specific, what makes you think you need Flask to use it?

@iongion
Copy link
Author

iongion commented Oct 25, 2016

I come from an ancient world of real time communications, using RTMP as protocol. There, you had the server that listened to 80 or 1935, it did not need a web app framework, the app logic was implemented through on_connect type of life-cycle.
In the example code, I really do not understand the role of the Flask application, I mean, I would like to use python-socketio as a pure websocket server and I did not find how. What if I want to use something else than Flask ?

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Oct 25, 2016

The role of the Flask app is to serve the client application to the browser. If you have a client that knows how to talk Socket.IO already, then you can remove all the Flask stuff from the example.

What if I want to use something else than Flask ?

Absolutely. The WSGI middleware included with this package can help you route traffic between a standard WSGI app and the Socket.IO server:

application = socketio.Middleware(sio, <your-favorite-wsgi-app-here>)

And if you don't want a WSGI app, just use the same middleware, but don't set the WSGI app:

application = socketio.Middleware(sio)

In both cases, application can be used with one of the supported WSGI servers.

In case this isn't clear, there is another package of mine called Flask-SocketIO that uses this package as a dependency and does have very strong ties to Flask. If you were to use Flask then Flask-SocketIO provides a good integration with the frameork, so that you can share user sessions between HTTP and socket routes, for example. This package does not have any of that, Flask is actually not a dependency (it is only for the example, for the reasons stated above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants