Download app.py from The-Chef/Doc: direct link, hf CLI and curl.
- Browser
- Download file 2.65 kB
-
https://huggingface.co/spaces/The-Chef/Doc/resolve/main/app.py
- Command line
-
hf download hf://spaces/The-Chef/Doc/app.py
-
curl -L -o app.py https://huggingface.co/spaces/The-Chef/Doc/resolve/main/app.py
2.65 kB
| 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" | |
| ] | |
| 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" | |
| } | |
| def get_status(): | |
| return { | |
| "status": "ONLINE", | |
| "api_name": "The-Chef's Epic API", | |
| "version": "2.0.0", | |
| "message": "Running smooth", | |
| "vibe": "Maximum coolness" | |
| } | |
| def random_fact(): | |
| return { | |
| "fact": random.choice(COOL_FACTS), | |
| "category": "Mind Blown" | |
| } | |
| def get_motivation(): | |
| return { | |
| "quote": random.choice(QUOTES), | |
| "message": "You got this!" | |
| } | |
| 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") | |
| } | |
| 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" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| ] | |
| ] |