Bird
0
0

How should you architect a Flask app to use WebSocket for real-time updates and fallback to polling for clients without WebSocket support?

hard📝 Application Q8 of 15
Flask - WebSocket and Real-Time
How should you architect a Flask app to use WebSocket for real-time updates and fallback to polling for clients without WebSocket support?
AUse polling endpoints only and ignore WebSocket support
BImplement WebSocket endpoints for real-time, and provide separate HTTP polling endpoints as fallback
CUse WebSocket endpoints and force all clients to upgrade to WebSocket
DCombine WebSocket and polling in the same endpoint using POST requests
Step-by-Step Solution
Solution:
  1. Step 1: Understand dual support

    WebSocket provides real-time updates; polling is fallback for unsupported clients.
  2. Step 2: Separate endpoints

    Maintain WebSocket endpoints for real-time and HTTP polling endpoints for fallback.
  3. Final Answer:

    Implement WebSocket endpoints for real-time, and provide separate HTTP polling endpoints as fallback -> Option B
  4. Quick Check:

    Separate endpoints ensure compatibility and maintainability [OK]
Quick Trick: Use separate endpoints for WebSocket and polling [OK]
Common Mistakes:
MISTAKES
  • Ignoring fallback for clients without WebSocket
  • Forcing all clients to use WebSocket
  • Mixing WebSocket and polling in one endpoint

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes