Bird
0
0

How can you modify an HTTP triggered function to log the request method and path before processing it?

hard📝 Application Q9 of 15
GCP - Cloud Functions
How can you modify an HTTP triggered function to log the request method and path before processing it?
Adef func(request): logger.info(request.method + request.path) return ('Done', 200)
Bdef func(request): log(request.method, request.path) return ('Done', 200)
Cdef func(request): print(f'Method: {request.method}, Path: {request.path}') return ('Done', 200)
Ddef func(request): return ('Done', 200)
Step-by-Step Solution
Solution:
  1. Step 1: Identify valid logging method

    Using print is a simple way to log in Cloud Functions.
  2. Step 2: Confirm access to method and path

    request.method and request.path provide HTTP method and URL path.
  3. Final Answer:

    Using print with f-string to log method and path -> Option C
  4. Quick Check:

    Print request.method and request.path logs info [OK]
Quick Trick: Use print(f'...') to log request details in Cloud Functions [OK]
Common Mistakes:
  • Using undefined log or logger without import
  • Concatenating strings without spaces
  • Not logging request details at all

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes