humza7656 commited on
Commit
f0dc501
·
verified ·
1 Parent(s): 0d51a63

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +33 -0
main.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ import requests
4
+ app=FastAPI()
5
+
6
+
7
+
8
+
9
+ app.add_middleware(
10
+ CORSMiddleware,
11
+ allow_origins=["*"],
12
+ allow_credentials=True,
13
+ allow_methods=["*"],
14
+ allow_headers=["*"],
15
+ )
16
+ @app.get('/')
17
+ def daddy_home():
18
+ return{
19
+ 'Daddy Jokes':'Where is baby oil???'
20
+ }
21
+
22
+ @app.get('/daddy_jokes')
23
+ def dadddy_jokes():
24
+ url="https://jokefather.com/api/jokes/random"
25
+ response=requests.get(url)
26
+ data=response.json()
27
+ joke_setup=data['setup']
28
+ joke_punchline=data['punchline']
29
+ return {
30
+ 'Daddy Jokes':'WELCOME DADDY!!',
31
+ 'Setup':joke_setup,
32
+ 'Punchline':joke_punchline
33
+ }