Route decorator syntax
📖 Scenario: You are building a simple web API using FastAPI. You want to create routes that respond to HTTP requests.
🎯 Goal: Create a FastAPI app with a route that responds to GET requests at the path /hello and returns a greeting message.
📋 What You'll Learn
Create a FastAPI app instance named
appDefine a route using the
@app.get decorator for the path /helloCreate a function named
hello that returns the string 'Hello, FastAPI!'💡 Why This Matters
🌍 Real World
Web APIs use route decorators to define how the server responds to different URLs and HTTP methods.
💼 Career
Understanding route decorators is essential for backend developers working with FastAPI or similar web frameworks.
Progress0 / 4 steps