Update app.py
Browse files1234467891056121314151617789101112131421222324151617181920282122233132333435363738394024252627284429303147323349505152343536555657585960613738394041646566676869424344457246474875764950515253548283555685868788575859606162636465from fastapi import FastAPIimport randomfrom datetime import datetimeimport platform
app = FastAPI( title="The-Chef's Epic API", description="A seriously cool API with multiple endpoints", version="2.0.0")app = FastAPI(title="The-Chef's Epic API", version="2.0.0")
COOL_FACTS = [ "Honey never spoils. Archaeologists have found 3000-year-old honey that's still edible.", "A group of flamingos is called a flamboyance.", "Octopuses have three hearts and blue blood.", "Bananas are berries, but strawberries are not.", "There are more stars in the universe than grains of sand on all Earth's beaches."FACTS = [ "Honey never spoils", "Octopuses have 3 hearts", "Bananas are berries", "Venus days are longer than its years"]
QUOTES = [ "The only way to do great work is to love what you do.", "Innovation distinguishes between a leader and a follower.", "The future belongs to those who believe in the beauty of their dreams.", "Success is not final, failure is not fatal: courage to continue counts." "Do great work - Steve Jobs", "Innovation distinguishes leaders - Steve Jobs", "Believe in your dreams - Eleanor Roosevelt"]
@app.get("/")def root():def home(): return { "message": "Welcome to The-Chef's Epic API!", "version": "2.0.0", "endpoints": [ "/status - Get system status", "/random-fact - Get a cool fact", "/motivate - Get motivated", "/time - Current time", "/hello/{name} - Personalized greeting", "/docs - API documentation" ], "coolness_level": "Over 9000!" "endpoints": ["/status", "/fact", "/motivate", "/time", "/hello/{name}", "/docs"], "coolness": "Maximum" }
@app.get("/status")def get_status():def status(): return { "status": "ONLINE", "api_name": "The-Chef's Epic API", "api": "The-Chef's Epic API", "version": "2.0.0", "platform": platform.system(), "python_version": platform.python_version(), "message": "Running smooth like butter", "coolness_level": "Maximum" "vibe": "Unstoppable" }
@app.get("/random-fact")def random_fact(): return { "fact": random.choice(COOL_FACTS), "category": "Mind Blown", "timestamp": datetime.now().isoformat() } @app.get("/fact")def get_fact(): return {"fact": random.choice(FACTS), "category": "Cool"}
@app.get("/motivate")def get_motivation(): return { "quote": random.choice(QUOTES), "message": "You got this!", "timestamp": datetime.now().isoformat() }def motivate(): return {"quote": random.choice(QUOTES), "message": "You got this!"}
@app.get("/time")def get_time():def time_now(): now = datetime.now() return { "current_time": now.isoformat(), "date": now.strftime("%Y-%m-%d"), "time": now.strftime("%H:%M:%S"), "date": now.strftime("%Y-%m-%d"), "day": now.strftime("%A") }
@app.get("/hello/{name}")def greet_user(name: str): greeting = random.choice(["Hey", "Hello", "Hi", "Yo"])def hello(name: str): return { "message": f"{greeting}, {name}!", "status": "You're awesome!", "boost": "+100 coolness points" } "message": f"{random.choice(['Hey', 'Hi', 'Yo'])}, {name}!", "boost": "+100 points" } } } } }]]app.py+32-55