-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.rickroll
54 lines (39 loc) · 1.53 KB
/
main.rickroll
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
take me to ur heart
# Imports
we know the fastapi
we know the uvicorn
we know the random
we know the json
# The fastapi app
give app up fastapi.FastAPI()
# Get list of facts/compliment/roasts from the json files
give list_of_facts up json.load(open("/home/runner/RicklangAPI/data/facts.json"))
give list_of_roasts up json.load(open("/home/runner/RicklangAPI/data/roastlist.json"))
give list_of_compliments up json.load(open("/home/runner/RicklangAPI/data/compliment.json"))
# home function for the "/" endpoint
gonna home
when i give my {"Hello World" : "From Rickroll-Lang"}
say goodbye
# function for the "/fact" endpoint
gonna fact
# picks a random fact from the list
when i give my random.choice(list_of_facts)
say goodbye
# function for the "/compliment" endpoint
gonna compliment
# picks a random compliment from the list
when i give my random.choice(list_of_compliments)
say goodbye
# function for the "/roast" endpoint
gonna roast
# picks a random roast from the list
when i give my random.choice(list_of_roasts)
say goodbye
# Adds the function to the app (cant do decorators)
give api_home_route up app.add_api_route("/", home)
give api_fact_route up app.add_api_route("/fact", fact)
give api_roast_route up app.add_api_route("/roast", roast)
give api_compliment_route up app.add_api_route("/compliment", compliment)
# Runs the app
py: uvicorn.run(app)
say goodbye