Update app.py
Browse files1234567891011121314151613 unmodified lines303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341 unmodified line1361371381391401411421431441451461471481491501511 unmodified line153154155156157158159from fastapi import FastAPIfrom fastapi.responses import HTMLResponseimport randomfrom datetime import datetimeimport platformapp = FastAPI(title="π₯ The-Chef's Epic API π₯",description="A seriously cool API with multiple endpoints",version="2.0.0")# Cool facts databaseCOOL_FACTS = ["Honey never spoils. Archaeologists have found 3000-year-old honey in Egyptian tombs that's still edible.","A group of flamingos is called a 'flamboyance'.",13 unmodified lines"Believe you can and you're halfway there. - Theodore Roosevelt"]@app.get("/", response_class=HTMLResponse)async def root():"""Welcome page with API documentation"""""html_content = """<html><head><title>The-Chef's Epic API</title><style>body {font-family: 'Courier New', monospace;background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);color: white;padding: 50px;text-align: center;}.container {background: rgba(0,0,0,0.3);border-radius: 20px;padding: 40px;max-width: 800px;margin: 0 auto;backdrop-filter: blur(10px);}h1 { font-size: 3em; margin-bottom: 20px; }.endpoint {background: rgba(255,255,255,0.1);padding: 15px;margin: 10px 0;border-radius: 10px;text-align: left;}a { color: #ffd700; text-decoration: none; font-weight: bold; }a:hover { text-decoration: underline; }</style></head><body><div class="""container"><h1>π The-Chef's Epic API π</h1><p>Welcome to the coolest API on Hugging Face Spaces!</p><h2>π‘ Available Endpoints:</h2><div class="endpoint"><strong>GET <a href="/status">/status</a></strong> - System status & info</div><div class="endpoint"><strong>GET <a href="/random-fact">/random-fact</a></strong> - Get a random cool fact</div><div class="endpoint"><strong>GET <a href="/motivate">/motivate</a></strong> - Get motivated!</div><div class="endpoint"><strong>GET <a href="/time">/time</a></strong> - Current server time</div><div class="endpoint"><strong>GET <a href="/docs">/docs</a></strong> - Interactive API documentation</div></div></body></html>"""return html_content@app.get("""/status")async def get_status():"""Get system status and information"""""return {"status": "π’ ONLINE","api_name": "The-Chef's Epic API","version": "2.0.0","platform": platform.system(),"python_version": platform.python_version(),"uptime_message": "Running smooth like butter π","endpoints_available": 6,"coolness_level": "Over 9000! π₯"}@app.get("/random-fact")async def random_fact():"""Get a random interesting fact"""""fact = random.choice(COOL_FACTS)return {"fact": fact,"category": "mind = blown π€―","timestamp": datetime.now().isoformat()}@app.get("/motivate")async def get_motivation():"""Get a motivational quote"""""quote = random.choice(MOTIVATIONAL_QUOTES)return {"quote": quote,"message": "You got this! πͺ","vibes": "Positive β¨","timestamp": datetime.now().isoformat()}@app.get("/time")async def get_time():"""Get current server time"""""now = datetime.now()return {"current_time": now.isoformat(),1 unmodified line"time": now.strftime("%H:%M:%S"),"day_of_week": now.strftime("%A"),"timezone": "UTC","message": "Time flies when you're having fun! β°"}@app.get("/hello/{name}")async def greet_user(name: str):"""Personalized greeting"""""greetings = ["Hey", "Hello", "Hi", "Yo", "What's up"]greeting = random.choice(greetings)return {"message": f"{greeting}, {name}! π","status": "You're awesome!","coolness_boost": "+100 points"}1 unmodified line}}}}]])123456789101112131413 unmodified lines28293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182831 unmodified line8586878889909192939495969798991 unmodified line101102103104105106107108109from fastapi import FastAPIimport randomfrom datetime import datetimeimport platformapp = FastAPI(title="The-Chef's Epic API",description="A seriously cool API with multiple endpoints",version="2.0.0")COOL_FACTS = ["Honey never spoils. Archaeologists have found 3000-year-old honey in Egyptian tombs that's still edible.","A group of flamingos is called a 'flamboyance'.",13 unmodified lines"Believe you can and you're halfway there. - Theodore Roosevelt"]@app.get("/")async def root():return {"message": "Welcome to The-Chef's Epic API!","version": "2.0.0","endpoints": {"/status": "Get system status and info","/random-fact": "Get a random cool fact","/motivate": "Get motivated with a quote","/time": "Get current server time","/hello/{name}": "Get a personalized greeting","/docs": "Interactive API documentation"},"coolness_level": "Over 9000!"}@app.get("/status")async def get_status():return {"status": "ONLINE","api_name": "The-Chef's Epic API","version": "2.0.0","platform": platform.system(),"python_version": platform.python_version(),"uptime_message": "Running smooth like butter","endpoints_available": 6,"coolness_level": "Over 9000!"}@app.get("/random-fact")async def random_fact():fact = random.choice(COOL_FACTS)return {"fact": fact,"category": "mind = blown","timestamp": datetime.now().isoformat()}@app.get("/motivate")async def get_motivation():quote = random.choice(MOTIVATIONAL_QUOTES)return {"quote": quote,"message": "You got this!","vibes": "Positive","timestamp": datetime.now().isoformat()}@app.get("/time")async def get_time():now = datetime.now()return {"current_time": now.isoformat(),1 unmodified line"time": now.strftime("%H:%M:%S"),"day_of_week": now.strftime("%A"),"timezone": "UTC","message": "Time flies when you're having fun!"}@app.get("/hello/{name}")async def greet_user(name: str):greetings = ["Hey", "Hello", "Hi", "Yo", "What's up"]greeting = random.choice(greetings)return {"message": f"{greeting}, {name}!","status": "You're awesome!","coolness_boost": "+100 points"}1 unmodified line}}}}}}]])
app.py+37-87