1

I have a simple app which has the following architecture:

front-end
   api/
back-end
   server.py
   api/
   utils/

The app is already using http based server which is started/configured in the server.py. However, now I would also like to use websockets for some new functionalities, while my old http -based code will still be used throughout the app.

My question is, should I create another, separate server for the websockets? Should I decouple the code from the server.py into two files (http server and websocket server)? What are the pros/cons for each approach and is it possible to use the same server for both, the http requests coming in and the websocket connections?

1

1 Answer 1

1

Not sure what you are looking to separate. Or what is your definition of app.

You can keep everything under server.py that is not an issue. However, do provide separate flask objects for HTTP and websockets.

HTTP can probably be handled by a threaded server. Websockets, on the other hand, are much more likely to be a bad idea to use threads. So let the deployment decide what runs what protocol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.