The-Chef commited on
Commit
b893bef
·
verified ·
1 Parent(s): b34a1b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -43
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 in Egyptian tombs 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 aren't.",
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
- MOTIVATIONAL_QUOTES = [
24
- "The only way to do great work is to love what you do. - Steve Jobs",
25
- "Innovation distinguishes between a leader and a follower. - Steve Jobs",
26
- "The future belongs to those who believe in the beauty of their dreams. - Eleanor Roosevelt",
27
- "Success is not final, failure is not fatal: it is the courage to continue that counts. - Winston Churchill",
28
- "Believe you can and you're halfway there. - Theodore Roosevelt"
29
  ]
30
 
31
  @app.get("/")
32
- async def root():
33
  return {
34
  "message": "Welcome to The-Chef's Epic API!",
35
  "version": "2.0.0",
36
- "endpoints": {
37
- "/status": "Get system status and info",
38
- "/random-fact": "Get a random cool fact",
39
- "/motivate": "Get motivated with a quote",
40
- "/time": "Get current server time",
41
- "/hello/{name}": "Get a personalized greeting",
42
- "/docs": "Interactive API documentation"
43
- },
44
  "coolness_level": "Over 9000!"
45
  }
46
 
47
  @app.get("/status")
48
- async def get_status():
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
- "uptime_message": "Running smooth like butter",
56
- "endpoints_available": 6,
57
- "coolness_level": "Over 9000!"
58
  }
59
 
60
  @app.get("/random-fact")
61
- async def random_fact():
62
- fact = random.choice(COOL_FACTS)
63
  return {
64
- "fact": fact,
65
- "category": "mind = blown",
66
  "timestamp": datetime.now().isoformat()
67
  }
68
 
69
  @app.get("/motivate")
70
- async def get_motivation():
71
- quote = random.choice(MOTIVATIONAL_QUOTES)
72
  return {
73
- "quote": quote,
74
  "message": "You got this!",
75
- "vibes": "Positive",
76
  "timestamp": datetime.now().isoformat()
77
  }
78
 
79
  @app.get("/time")
80
- async def get_time():
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
- "day_of_week": now.strftime("%A"),
87
- "timezone": "UTC",
88
- "message": "Time flies when you're having fun!"
89
  }
90
 
91
  @app.get("/hello/{name}")
92
- async def greet_user(name: str):
93
- greetings = ["Hey", "Hello", "Hi", "Yo", "What's up"]
94
- greeting = random.choice(greetings)
95
  return {
96
  "message": f"{greeting}, {name}!",
97
  "status": "You're awesome!",
98
- "coolness_boost": "+100 points"
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
  ]