MingDoan commited on
Commit
52c0de0
0 Parent(s):

feat: Update Inference

Browse files
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ env/
README.md ADDED
File without changes
app.py ADDED
File without changes
controllers/fw.py ADDED
File without changes
requirements.txt ADDED
Binary file (2.43 kB). View file
 
services/api_service.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from requests import get, post, put, delete
2
+ from utils.constants import API_ENDPOINT
3
+
4
+
5
+ def get_data(url, params=None, parse_json=True):
6
+ if url.startswith("/"):
7
+ url = API_ENDPOINT + url
8
+ response = get(url, params=params)
9
+ if response.status_code == 200:
10
+ if parse_json:
11
+ return response.json()
12
+ else:
13
+ return response.content
14
+ else:
15
+ return None
16
+
17
+
18
+ def post_data(url, json=None, files=None, parse_json=True):
19
+ if url.startswith("/"):
20
+ url = API_ENDPOINT + url
21
+ response = post(url, json=json, files=files)
22
+ if response.status_code == 200:
23
+ if parse_json:
24
+ return response.json()
25
+ else:
26
+ return response.content
27
+ else:
28
+ return None
29
+
30
+
31
+ def put_data(url, json=None, parse_json=True):
32
+ if url.startswith("/"):
33
+ url = API_ENDPOINT + url
34
+ response = put(url, json=json)
35
+ if response.status_code == 200:
36
+ if parse_json:
37
+ return response.json()
38
+ else:
39
+ return response.content
40
+ else:
41
+ return None
42
+
43
+
44
+ def delete_data(url, parse_json=True):
45
+ if url.startswith("/"):
46
+ url = API_ENDPOINT + url
47
+ response = delete(url)
48
+ if response.status_code == 200:
49
+ if parse_json:
50
+ return response.json()
51
+ else:
52
+ return response.content
53
+ else:
54
+ return None
utils/constants.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ API_ENDPOINT = "https://gdscfptu-ai-service-hf.hf.space"
2
+ FW_DEFAULT_OPTION = "none"