Complete the code to define a service class method that returns a greeting message.
class GreetingService: def get_greeting(self): return [1]
The method should return a string greeting. Option B correctly returns the string.
Complete the Flask route to call the service method and return its result.
from flask import Flask app = Flask(__name__) service = GreetingService() @app.route('/') def home(): return [1]
The route function must call the service method with parentheses to get the greeting string.
Fix the error in the service method to accept a name parameter and return a personalized greeting.
class GreetingService: def get_greeting(self, [1]): return f"Hello, {name}!"
The method must accept a parameter named 'name' to use it in the greeting string.
Fill both blanks to update the Flask route to accept a name URL parameter and pass it to the service.
from flask import Flask, request app = Flask(__name__) service = GreetingService() @app.route('/hello/<[1]>') def hello(): name = request.view_args.get('[2]') return service.get_greeting(name)
The URL parameter and the key to get it from view_args must both be 'name' to match.
Fill all three blanks to create a service method that validates input and returns a message accordingly.
class GreetingService: def get_greeting(self, name): if not name or len(name) [1] 0: return [2] return f"Hello, {name}[3]"
The method checks if name is empty or length is less or equal to zero, returns a default greeting, else returns personalized greeting with exclamation.