The-Chef commited on
Commit
05e2676
·
verified ·
1 Parent(s): 5ff4d8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -55
app.py CHANGED
@@ -1,88 +1,65 @@
1
  from fastapi import FastAPI
2
  import random
3
  from datetime import datetime
4
- import platform
5
 
6
- app = FastAPI(
7
- title="The-Chef's Epic API",
8
- description="A seriously cool API with multiple endpoints",
9
- version="2.0.0"
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
- }
 
 
 
 
 
 
1
  from fastapi import FastAPI
2
  import random
3
  from datetime import datetime
 
4
 
5
+ app = FastAPI(title="The-Chef's Epic API", version="2.0.0")
 
 
 
 
6
 
7
+ FACTS = [
8
+ "Honey never spoils",
9
+ "Octopuses have 3 hearts",
10
+ "Bananas are berries",
11
+ "Venus days are longer than its years"
 
12
  ]
13
 
14
  QUOTES = [
15
+ "Do great work - Steve Jobs",
16
+ "Innovation distinguishes leaders - Steve Jobs",
17
+ "Believe in your dreams - Eleanor Roosevelt"
 
18
  ]
19
 
20
  @app.get("/")
21
+ def home():
22
  return {
23
  "message": "Welcome to The-Chef's Epic API!",
24
+ "endpoints": ["/status", "/fact", "/motivate", "/time", "/hello/{name}", "/docs"],
25
+ "coolness": "Maximum"
 
 
 
 
 
 
 
 
26
  }
27
 
28
  @app.get("/status")
29
+ def status():
30
  return {
31
  "status": "ONLINE",
32
+ "api": "The-Chef's Epic API",
33
  "version": "2.0.0",
34
+ "vibe": "Unstoppable"
 
 
 
35
  }
36
 
37
+ @app.get("/fact")
38
+ def get_fact():
39
+ return {"fact": random.choice(FACTS), "category": "Cool"}
 
 
 
 
40
 
41
  @app.get("/motivate")
42
+ def motivate():
43
+ return {"quote": random.choice(QUOTES), "message": "You got this!"}
 
 
 
 
44
 
45
  @app.get("/time")
46
+ def time_now():
47
  now = datetime.now()
48
  return {
 
 
49
  "time": now.strftime("%H:%M:%S"),
50
+ "date": now.strftime("%Y-%m-%d"),
51
  "day": now.strftime("%A")
52
  }
53
 
54
  @app.get("/hello/{name}")
55
+ def hello(name: str):
 
56
  return {
57
+ "message": f"{random.choice(['Hey', 'Hi', 'Yo'])}, {name}!",
58
+ "boost": "+100 points"
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ ]
65
+ ]