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?

asked Jun 23, 2020 at 13:26
1
  • You should look at FastAPI Commented Dec 4, 2020 at 20:30

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.

answered Jul 7, 2020 at 19:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.