Update app.py
Browse files
app.py
CHANGED
|
@@ -10,99 +10,88 @@ app = FastAPI(
|
|
| 10 |
)
|
| 11 |
|
| 12 |
COOL_FACTS = [
|
| 13 |
-
"Honey never spoils. Archaeologists have found 3000-year-old honey
|
| 14 |
-
"A group of flamingos is called a
|
| 15 |
"Octopuses have three hearts and blue blood.",
|
| 16 |
-
"Bananas are berries, but strawberries
|
| 17 |
-
"There are more stars in the universe than grains of sand on all Earth's beaches."
|
| 18 |
-
"Water can boil and freeze at the same time (triple point).",
|
| 19 |
-
"A day on Venus is longer than its year.",
|
| 20 |
-
"Your body produces enough heat in 30 minutes to bring water to a boil."
|
| 21 |
]
|
| 22 |
|
| 23 |
-
|
| 24 |
-
"The only way to do great work is to love what you do.
|
| 25 |
-
"Innovation distinguishes between a leader and a follower.
|
| 26 |
-
"The future belongs to those who believe in the beauty of their dreams.
|
| 27 |
-
"Success is not final, failure is not fatal:
|
| 28 |
-
"Believe you can and you're halfway there. - Theodore Roosevelt"
|
| 29 |
]
|
| 30 |
|
| 31 |
@app.get("/")
|
| 32 |
-
|
| 33 |
return {
|
| 34 |
"message": "Welcome to The-Chef's Epic API!",
|
| 35 |
"version": "2.0.0",
|
| 36 |
-
"endpoints":
|
| 37 |
-
"/status
|
| 38 |
-
"/random-fact
|
| 39 |
-
"/motivate
|
| 40 |
-
"/time
|
| 41 |
-
"/hello/{name}
|
| 42 |
-
"/docs
|
| 43 |
-
|
| 44 |
"coolness_level": "Over 9000!"
|
| 45 |
}
|
| 46 |
|
| 47 |
@app.get("/status")
|
| 48 |
-
|
| 49 |
return {
|
| 50 |
"status": "ONLINE",
|
| 51 |
"api_name": "The-Chef's Epic API",
|
| 52 |
"version": "2.0.0",
|
| 53 |
"platform": platform.system(),
|
| 54 |
"python_version": platform.python_version(),
|
| 55 |
-
"
|
| 56 |
-
"
|
| 57 |
-
"coolness_level": "Over 9000!"
|
| 58 |
}
|
| 59 |
|
| 60 |
@app.get("/random-fact")
|
| 61 |
-
|
| 62 |
-
fact = random.choice(COOL_FACTS)
|
| 63 |
return {
|
| 64 |
-
"fact":
|
| 65 |
-
"category": "
|
| 66 |
"timestamp": datetime.now().isoformat()
|
| 67 |
}
|
| 68 |
|
| 69 |
@app.get("/motivate")
|
| 70 |
-
|
| 71 |
-
quote = random.choice(MOTIVATIONAL_QUOTES)
|
| 72 |
return {
|
| 73 |
-
"quote":
|
| 74 |
"message": "You got this!",
|
| 75 |
-
"vibes": "Positive",
|
| 76 |
"timestamp": datetime.now().isoformat()
|
| 77 |
}
|
| 78 |
|
| 79 |
@app.get("/time")
|
| 80 |
-
|
| 81 |
now = datetime.now()
|
| 82 |
return {
|
| 83 |
"current_time": now.isoformat(),
|
| 84 |
"date": now.strftime("%Y-%m-%d"),
|
| 85 |
"time": now.strftime("%H:%M:%S"),
|
| 86 |
-
"
|
| 87 |
-
"timezone": "UTC",
|
| 88 |
-
"message": "Time flies when you're having fun!"
|
| 89 |
}
|
| 90 |
|
| 91 |
@app.get("/hello/{name}")
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
greeting = random.choice(greetings)
|
| 95 |
return {
|
| 96 |
"message": f"{greeting}, {name}!",
|
| 97 |
"status": "You're awesome!",
|
| 98 |
-
"
|
| 99 |
}
|
| 100 |
}
|
| 101 |
}
|
| 102 |
}
|
| 103 |
}
|
| 104 |
}
|
| 105 |
-
|
| 106 |
}
|
| 107 |
]
|
| 108 |
]
|
|
|
|
| 10 |
)
|
| 11 |
|
| 12 |
COOL_FACTS = [
|
| 13 |
+
"Honey never spoils. Archaeologists have found 3000-year-old honey that's still edible.",
|
| 14 |
+
"A group of flamingos is called a flamboyance.",
|
| 15 |
"Octopuses have three hearts and blue blood.",
|
| 16 |
+
"Bananas are berries, but strawberries are not.",
|
| 17 |
+
"There are more stars in the universe than grains of sand on all Earth's beaches."
|
|
|
|
|
|
|
|
|
|
| 18 |
]
|
| 19 |
|
| 20 |
+
QUOTES = [
|
| 21 |
+
"The only way to do great work is to love what you do.",
|
| 22 |
+
"Innovation distinguishes between a leader and a follower.",
|
| 23 |
+
"The future belongs to those who believe in the beauty of their dreams.",
|
| 24 |
+
"Success is not final, failure is not fatal: courage to continue counts."
|
|
|
|
| 25 |
]
|
| 26 |
|
| 27 |
@app.get("/")
|
| 28 |
+
def root():
|
| 29 |
return {
|
| 30 |
"message": "Welcome to The-Chef's Epic API!",
|
| 31 |
"version": "2.0.0",
|
| 32 |
+
"endpoints": [
|
| 33 |
+
"/status - Get system status",
|
| 34 |
+
"/random-fact - Get a cool fact",
|
| 35 |
+
"/motivate - Get motivated",
|
| 36 |
+
"/time - Current time",
|
| 37 |
+
"/hello/{name} - Personalized greeting",
|
| 38 |
+
"/docs - API documentation"
|
| 39 |
+
],
|
| 40 |
"coolness_level": "Over 9000!"
|
| 41 |
}
|
| 42 |
|
| 43 |
@app.get("/status")
|
| 44 |
+
def get_status():
|
| 45 |
return {
|
| 46 |
"status": "ONLINE",
|
| 47 |
"api_name": "The-Chef's Epic API",
|
| 48 |
"version": "2.0.0",
|
| 49 |
"platform": platform.system(),
|
| 50 |
"python_version": platform.python_version(),
|
| 51 |
+
"message": "Running smooth like butter",
|
| 52 |
+
"coolness_level": "Maximum"
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
@app.get("/random-fact")
|
| 56 |
+
def random_fact():
|
|
|
|
| 57 |
return {
|
| 58 |
+
"fact": random.choice(COOL_FACTS),
|
| 59 |
+
"category": "Mind Blown",
|
| 60 |
"timestamp": datetime.now().isoformat()
|
| 61 |
}
|
| 62 |
|
| 63 |
@app.get("/motivate")
|
| 64 |
+
def get_motivation():
|
|
|
|
| 65 |
return {
|
| 66 |
+
"quote": random.choice(QUOTES),
|
| 67 |
"message": "You got this!",
|
|
|
|
| 68 |
"timestamp": datetime.now().isoformat()
|
| 69 |
}
|
| 70 |
|
| 71 |
@app.get("/time")
|
| 72 |
+
def get_time():
|
| 73 |
now = datetime.now()
|
| 74 |
return {
|
| 75 |
"current_time": now.isoformat(),
|
| 76 |
"date": now.strftime("%Y-%m-%d"),
|
| 77 |
"time": now.strftime("%H:%M:%S"),
|
| 78 |
+
"day": now.strftime("%A")
|
|
|
|
|
|
|
| 79 |
}
|
| 80 |
|
| 81 |
@app.get("/hello/{name}")
|
| 82 |
+
def greet_user(name: str):
|
| 83 |
+
greeting = random.choice(["Hey", "Hello", "Hi", "Yo"])
|
|
|
|
| 84 |
return {
|
| 85 |
"message": f"{greeting}, {name}!",
|
| 86 |
"status": "You're awesome!",
|
| 87 |
+
"boost": "+100 coolness points"
|
| 88 |
}
|
| 89 |
}
|
| 90 |
}
|
| 91 |
}
|
| 92 |
}
|
| 93 |
}
|
| 94 |
+
]
|
| 95 |
}
|
| 96 |
]
|
| 97 |
]
|