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

Add WebSocket Examples #152

Open
DeanNeaht opened this issue Mar 27, 2023 · 6 comments
Open

Add WebSocket Examples #152

DeanNeaht opened this issue Mar 27, 2023 · 6 comments

Comments

@DeanNeaht
Copy link
Contributor

Hello,

I noticed that the current version of the FastAPI-Template project does not include examples of using WebSockets with FastAPI. I think adding these examples would be helpful for developers.

It's worth noting that DI for WebSockets is different from DI for HTTP routes and testing.

I want to suggest adding examples of using WebSockets to the project.

I'm willing to help with this and can provide code examples as needed.

@s3rius
Copy link
Owner

s3rius commented Mar 27, 2023

Hi, and thanks for trying to make fastapi-template even better.

That's a good idea. I'll look into it this evening. Can you provide some ideas what should be done in this example? Simple echo server, or maybe something more mature?

@DeanNeaht
Copy link
Contributor Author

I believe that a simple echo server and an example with a dummy model would be good examples to include in the project.

In the dummy model example, we could have clients subscribe to changes in the model, and have the server broadcast updates to all connected clients. This would demonstrate how WebSockets can be used to create real-time, collaborative applications.

@s3rius
Copy link
Owner

s3rius commented Mar 28, 2023

I guess that subscribing for a model updates is a very big example. Maybe small message broadcasting would be enough? Like if someone writes a message, it sends to all connected people?

But I'm not sure that this is what is really needed, since these examples are exist here in fastapi docs.

@s3rius
Copy link
Owner

s3rius commented Mar 28, 2023

I don't really want to create a really big example, since it would be hard to support. But what I really like is the idea to show the example how to test websockets. So maybe echo or broadcast is enough.

@DeanNeaht
Copy link
Contributor Author

I agree that subscribing to model updates may be a big example, and a simple echo or broadcast may be sufficient.

However, I would still like to propose including an example that demonstrates the proper use of DI with WebSockets. Because, there are issues with DI in FastAPI that are not well-documented, and I believe that including an example would be very helpful for developers who are new to FastAPI or WebSockets.

In fact, I recently came across a discussion on GitHub where this issue was raised. Here is the link. As you can see, there are developers who have experienced problems with DI in FastAPI and would benefit from a clear example.

@eggb4by
Copy link

eggb4by commented Jun 20, 2023

I agree that subscribing to model updates may be a big example, and a simple echo or broadcast may be sufficient.

However, I would still like to propose including an example that demonstrates the proper use of DI with WebSockets. Because, there are issues with DI in FastAPI that are not well-documented, and I believe that including an example would be very helpful for developers who are new to FastAPI or WebSockets.

In fact, I recently came across a discussion on GitHub where this issue was raised. Here is the link. As you can see, there are developers who have experienced problems with DI in FastAPI and would benefit from a clear example.

I have same issue now....

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

No branches or pull requests

3 participants