27 lines
476 B
Python
27 lines
476 B
Python
from fastapi import FastAPI
|
|
|
|
app = FastAPI(
|
|
title="FastAPI Demo",
|
|
description="My first application with FastAPI",
|
|
version="1.0.0",
|
|
)
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"message": "Hello from FastAPI!",
|
|
"application": "fastapi-demo",
|
|
"version": "1.0.0",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "ok"}
|
|
|
|
|
|
@app.get("/hello/{name}")
|
|
async def hello(name: str):
|
|
return {"message": f"Hello, {name}!"}
|