wowkin2 / django-test-streaming-response

Repo to show how Django StreamingHttpResponse works with async views
5 stars 0 forks source link

About repository:

This is a repository prepared for answer on StackOverflow to have ability to download code and test it.

Question is about Django StreamingHttpResponse in async Django views. Look here for more details.

How to use it:

Run Django web-server using Daphne:

daphne -b 0.0.0.0 -p 8000 webapp.webapp.asgi:application

NOTE: I have 2 levels folder, but this is just because copy-paste from my test project. In yours it still can be sse_demo.asgi:application

Run script to check view:

python test_stream.py

Sync:

Uncomment line in test_stream.py:

r = requests.get('http://localhost:8000/sse', stream=True)

ASync:

Uncomment line in test_stream.py:

r = requests.get('http://localhost:8000/sse_async', stream=True)