Bird
0
0

What is wrong with this polling endpoint code snippet? ```python @app.route('/poll', methods=['POST']) def poll(): return jsonify({'status': 'ok'}) ```

medium📝 Debug Q7 of 15
Flask - WebSocket and Real-Time
What is wrong with this polling endpoint code snippet? ```python @app.route('/poll', methods=['POST']) def poll(): return jsonify({'status': 'ok'}) ```
AFunction must return a string, not jsonify
Bjsonify is not imported
CRoute path '/poll' is invalid
DPolling should use GET method, not POST
Step-by-Step Solution
Solution:
  1. Step 1: Check HTTP method for polling

    Polling typically uses GET requests to fetch data repeatedly without side effects.
  2. Step 2: Identify method mismatch

    Using POST means client must send data, which is not usual for polling.
  3. Final Answer:

    Polling should use GET method, not POST -> Option D
  4. Quick Check:

    Polling uses GET, not POST [OK]
Quick Trick: Polling endpoints usually respond to GET, not POST [OK]
Common Mistakes:
MISTAKES
  • Using POST instead of GET for polling
  • Assuming jsonify import error without context
  • Thinking route path is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes