| from fastapi import FastAPI |
| import random |
| from datetime import datetime |
|
|
| app = FastAPI(title="The-Chef's Epic API", version="2.0.0") |
|
|
| FACTS = [ |
| "Honey never spoils", |
| "Octopuses have 3 hearts", |
| "Bananas are berries", |
| "Venus days are longer than its years" |
| ] |
|
|
| QUOTES = [ |
| "Do great work - Steve Jobs", |
| "Innovation distinguishes leaders - Steve Jobs", |
| "Believe in your dreams - Eleanor Roosevelt" |
| ] |
|
|
| @app.get("/") |
| def home(): |
| return { |
| "message": "Welcome to The-Chef's Epic API!", |
| "endpoints": ["/status", "/fact", "/motivate", "/time", "/hello/{name}", "/docs"], |
| "coolness": "Maximum" |
| } |
|
|
| @app.get("/status") |
| def status(): |
| return { |
| "status": "ONLINE", |
| "api": "The-Chef's Epic API", |
| "version": "2.0.0", |
| "vibe": "Unstoppable" |
| } |
|
|
| @app.get("/fact") |
| def get_fact(): |
| return {"fact": random.choice(FACTS), "category": "Cool"} |
|
|
| @app.get("/motivate") |
| def motivate(): |
| return {"quote": random.choice(QUOTES), "message": "You got this!"} |
|
|
| @app.get("/time") |
| def time_now(): |
| now = datetime.now() |
| return { |
| "time": now.strftime("%H:%M:%S"), |
| "date": now.strftime("%Y-%m-%d"), |
| "day": now.strftime("%A") |
| } |
|
|
| @app.get("/hello/{name}") |
| def hello(name: str): |
| return { |
| "message": f"{random.choice(['Hey', 'Hi', 'Yo'])}, {name}!", |
| "boost": "+100 points" |
| } |
| } |
| } |
| } |
| } |
| ] |
| ] |