-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathapp.py
More file actions
46 lines (38 loc) · 1.08 KB
/
app.py
File metadata and controls
46 lines (38 loc) · 1.08 KB
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
import requests
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/posts')
def get_posts():
url = "https://jsonplaceholder.typicode.com/posts"
payload = {}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
return jsonify({
"data": response.json(),
"status": "successfully",
"status_code": 200
})
@app.route('/comments')
def get_comments():
url = "https://jsonplaceholder.typicode.com/comments"
payload = {}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
return jsonify({
"data": response.json(),
"status": "success",
"status_code": 200
})
@app.route('/albums')
def get_albums():
url = "https://jsonplaceholder.typicode.com/albums"
payload = {}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
return jsonify({
"data": response.json(),
"status": "success",
"status_code": 200
})
if __name__ == '__main__':
app.run(debug=True)