File size: 2,646 Bytes
c3f3e5a
1e3f83d
 
c3f3e5a
05e2676
c3f3e5a
52ee136
 
 
 
 
1e3f83d
 
b893bef
52ee136
 
 
1e3f83d
 
b34a1b6
05e2676
b34a1b6
 
52ee136
 
 
 
 
 
 
 
 
 
b34a1b6
1e3f83d
b34a1b6
52ee136
b34a1b6
 
52ee136
b34a1b6
52ee136
 
b34a1b6
 
05e2676
52ee136
 
 
 
 
1e3f83d
 
52ee136
 
 
 
 
1e3f83d
 
52ee136
1e3f83d
 
52ee136
05e2676
52ee136
b893bef
1e3f83d
 
 
52ee136
 
1e3f83d
52ee136
 
 
 
 
05e2676
 
 
 
52ee136
05e2676
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from fastapi import FastAPI
import random
from datetime import datetime

app = FastAPI(title="The-Chef's Epic API", version="2.0.0")

COOL_FACTS = [
        "Honey never spoils - 3000 year old honey is still edible",
        "Octopuses have three hearts and blue blood",
        "Bananas are berries but strawberries aren't",
        "A day on Venus is longer than its year"
]

QUOTES = [
        "The only way to do great work is to love what you do - Steve Jobs",
        "Innovation distinguishes between a leader and a follower - Steve Jobs",
        "Believe you can and you're halfway there - Theodore Roosevelt"
]

@app.get("/")
def home():
        return {
                    "message": "Welcome to The-Chef's Epic API!",
                    "version": "2.0.0",
                    "endpoints": {
                                    "/status": "System status and info",
                                    "/fact": "Random cool fact",
                                    "/motivate": "Motivational quote",
                                    "/time": "Current server time",
                                    "/hello/{name}": "Personal greeting",
                                    "/docs": "API documentation"
                    },
                    "coolness_level": "Over 9000"
        }

    @app.get("/status")
def get_status():
        return {
                    "status": "ONLINE",
                    "api_name": "The-Chef's Epic API",
                    "version": "2.0.0",
                    "message": "Running smooth",
                    "vibe": "Maximum coolness"
        }

    @app.get("/fact")
def random_fact():
        return {
                    "fact": random.choice(COOL_FACTS),
                    "category": "Mind Blown"
        }

    @app.get("/motivate")
def get_motivation():
        return {
                    "quote": random.choice(QUOTES),
                    "message": "You got this!"
        }

    @app.get("/time")
def get_time():
        now = datetime.now()
        return {
                    "current_time": now.isoformat(),
                    "date": now.strftime("%Y-%m-%d"),
                    "time": now.strftime("%H:%M:%S"),
                    "day": now.strftime("%A")
        }

    @app.get("/hello/{name}")
def greet_user(name: str):
        greeting = random.choice(["Hey", "Hello", "Hi", "Yo", "What's up"])
        return {
                    "message": f"{greeting}, {name}!",
                    "status": "You're awesome",
                    "coolness_boost": "+100"
        }
        }
        }
        }
        }
        }
                    }
        }
]
]