|
|
from fastapi import FastAPI |
|
|
import random |
|
|
from datetime import datetime |
|
|
|
|
|
app = FastAPI(title="The-Chef's Epic API", version="2.0.0") |
|
|
|
|
|
COOL_FACTS = [ |
|
|
"Honey never spoils - 3000 year old honey is still edible", |
|
|
"Octopuses have three hearts and blue blood", |
|
|
"Bananas are berries but strawberries aren't", |
|
|
"A day on Venus is longer than its year" |
|
|
] |
|
|
|
|
|
QUOTES = [ |
|
|
"The only way to do great work is to love what you do - Steve Jobs", |
|
|
"Innovation distinguishes between a leader and a follower - Steve Jobs", |
|
|
"Believe you can and you're halfway there - Theodore Roosevelt" |
|
|
] |
|
|
|
|
|
@app.get("/") |
|
|
def home(): |
|
|
return { |
|
|
"message": "Welcome to The-Chef's Epic API!", |
|
|
"version": "2.0.0", |
|
|
"endpoints": { |
|
|
"/status": "System status and info", |
|
|
"/fact": "Random cool fact", |
|
|
"/motivate": "Motivational quote", |
|
|
"/time": "Current server time", |
|
|
"/hello/{name}": "Personal greeting", |
|
|
"/docs": "API documentation" |
|
|
}, |
|
|
"coolness_level": "Over 9000" |
|
|
} |
|
|
|
|
|
@app.get("/status") |
|
|
def get_status(): |
|
|
return { |
|
|
"status": "ONLINE", |
|
|
"api_name": "The-Chef's Epic API", |
|
|
"version": "2.0.0", |
|
|
"message": "Running smooth", |
|
|
"vibe": "Maximum coolness" |
|
|
} |
|
|
|
|
|
@app.get("/fact") |
|
|
def random_fact(): |
|
|
return { |
|
|
"fact": random.choice(COOL_FACTS), |
|
|
"category": "Mind Blown" |
|
|
} |
|
|
|
|
|
@app.get("/motivate") |
|
|
def get_motivation(): |
|
|
return { |
|
|
"quote": random.choice(QUOTES), |
|
|
"message": "You got this!" |
|
|
} |
|
|
|
|
|
@app.get("/time") |
|
|
def get_time(): |
|
|
now = datetime.now() |
|
|
return { |
|
|
"current_time": now.isoformat(), |
|
|
"date": now.strftime("%Y-%m-%d"), |
|
|
"time": now.strftime("%H:%M:%S"), |
|
|
"day": now.strftime("%A") |
|
|
} |
|
|
|
|
|
@app.get("/hello/{name}") |
|
|
def greet_user(name: str): |
|
|
greeting = random.choice(["Hey", "Hello", "Hi", "Yo", "What's up"]) |
|
|
return { |
|
|
"message": f"{greeting}, {name}!", |
|
|
"status": "You're awesome", |
|
|
"coolness_boost": "+100" |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
] |
|
|
] |