Quiz Space

Modern Application Development II · End Term · 1 Sept 2024 · May 2024 term

Question 30: Which code snippet represents a Pub/Sub implementation?

Question 30

+2 marksOne correct option

Options:

A.

python
import requests
response = requests.get('https://some-api')
print(response.json())

B.

python
from flask import Flask, request
app = Flask(__name__)
@app.route('/server-route, methods=['POST'])
def server_route():
data = request.json
print(data)
return 'OK', 200

C.

python
from flask import Flask, Response
import time
app = Flask(__name__)
def stream():
while True:
time.sleep(5)
yield f'data: The time is {time.strftime("%Y-%m-%d %H:%M:%S")}\n\n'
@app.route('/server-route')
def server_route():
return Response(stream(), mimetype='text/event-stream')
if __name__ == '__main__':
app.run(debug=True, port=5000)

D.

python
import time
import requests
while True:
response = requests.get('https://some-endpoint')
print(response.json())
time.sleep(10)

Based on the above data, answer the given subquestions.

Which code snippet represents a Pub/Sub implementation?

  1. A

    A

  2. B

    B

  3. C

    C

  4. D

    D

Show answer

Correct answer

  • C

    C

Question 30 of 32 in the IIT Madras BS Modern Application Development II (MAD 2) End Term paper sat on 1 Sept 2024, in the May 2024 term (IIT M FOUNDATION DIPLOMA FN EXAM QDF1 01 Sep 2024). It carries 2 marks.

More questions from this paper

  1. Q1What of the following is the primary objective of a CSRF token?
  2. Q2Suppose an application is being loaded from the origin https://example.com. Which of the following origins will the bro…
  3. Q3What is the correct sequence of steps to update the state in Vuex when handling an asynchronous operation?
  4. Q4Suppose you are developing an application for millions of users that will perform intensive data analysis and return th…
  5. Q5Which of the following statements about Redis is true?
  6. Q6Which of the following scenarios is an example of a Cross-Site Request Forgery (CSRF) attack?
  7. Q7Match the following technologies with their typical use cases:
  8. Q8Consider the below javascript program. What will be the output of the above program, if executed?
  9. Q9Consider the following JavaScript code snippet. What will be the values of 'storedUsername', 'removedUsername', and 'cl…
  10. Q10Consider the following javascript code What are the values of regularResult and arrowResult?
  11. Q11Consider the below 2 approaches: Approach 1: Approach 2: Choose the correct statement:
  12. Q12Consider the below JavaScript program. What will be the output of the above program, if executed? Also, predict the min…
  13. Q13Which of the following statement(s) is/are true about webhooks?
  14. Q14Which of the following statement(s) is/are true regarding javascript?
  15. Q15Which of the following scenarios are best suited for using Celery tasks?
  16. Q16Which of the following statements is/are true regarding webhooks and server sent events (SSE)?
  17. Q17Which of the following is/are the correct ways to achieve the following.\ Always apply class named “errorClass”,\ The c…
  18. Q18Which of the following is/are true about Server-Sent Events (SSE)?
  19. Q19Which of the following HTTP header(s) can be used to control caching behavior in web applications?
  20. Q20Which of the following statement(s) is/are true regarding long and short polling?
  21. Q21Consider the following Vue.js 2 component using CDN. After entering "Orange" in the input box and clicking the "Add" bu…
  22. Q22Consider the following javascript code running on browser What will be the output in the browser console?
  23. Q23Consider the below JavaScript program. What will be the output of the above program?
  24. Q24Consider the below flask application. If the application is running on “http://127.0.0.1:5000” and the user visits the …
  25. Q25Consider the below JavaScript program. What will be the output of the above program?
  26. Q26In a Vue CLI project with Vuex, you have the following configuration: src/store/index.js: src/App.vue: After running “n…
  27. Q27Consider the below JavaScript code. Suppose the API URL “<u>https://example.com/api/users/23</u>” returns a valid HTML …
  28. Q28Consider the following Flask application with Redis caching. Redis is running normally on port 6379. Two requests are g…
  29. Q29Which code snippet represents a Webhook receiver implementation?
  30. Q31Filename: script.js
  31. Q32Filename: script.js