yuripeyamashita
commited on
Commit
•
1bb9b5d
1
Parent(s):
ee3e7dd
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
from flask import Flask, request
|
2 |
-
import os, json
|
3 |
import requests
|
4 |
|
5 |
app = Flask(__name__)
|
6 |
|
7 |
-
secret = os.environ.get("
|
8 |
headers = {'Authorization': os.environ.get("auth")}
|
9 |
|
10 |
res = {}
|
@@ -13,27 +13,46 @@ res = {}
|
|
13 |
def queue():
|
14 |
if request.json.get('secret') != secret:
|
15 |
return {}, 400
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
res[uuid] = response
|
21 |
print(res[uuid])
|
22 |
-
return
|
23 |
|
24 |
-
@app.route('/
|
25 |
-
def
|
26 |
-
|
27 |
-
data =
|
28 |
if not data:
|
29 |
return {}, 400
|
|
|
30 |
print(data)
|
|
|
31 |
URL = data.get('URL')
|
32 |
-
|
33 |
|
34 |
-
response = requests.post(URL, json=
|
|
|
|
|
|
|
35 |
|
36 |
return response.json()
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
if __name__ == "__main__":
|
39 |
app.run(host="0.0.0.0", port=7860)
|
|
|
1 |
from flask import Flask, request
|
2 |
+
import os, json, uuid
|
3 |
import requests
|
4 |
|
5 |
app = Flask(__name__)
|
6 |
|
7 |
+
secret = os.environ.get("auth")
|
8 |
headers = {'Authorization': os.environ.get("auth")}
|
9 |
|
10 |
res = {}
|
|
|
13 |
def queue():
|
14 |
if request.json.get('secret') != secret:
|
15 |
return {}, 400
|
16 |
+
|
17 |
+
uuid = str(uuid.uuid4())
|
18 |
+
res[uuid] = request.json
|
19 |
+
|
|
|
20 |
print(res[uuid])
|
21 |
+
return {'uuid': uuid}, 200
|
22 |
|
23 |
+
@app.route('/asr', methods=['GET'])
|
24 |
+
def asr():
|
25 |
+
uuid = request.args.get('uuid')
|
26 |
+
data = res.get(uuid)
|
27 |
if not data:
|
28 |
return {}, 400
|
29 |
+
|
30 |
print(data)
|
31 |
+
|
32 |
URL = data.get('URL')
|
33 |
+
body = data.get('body')
|
34 |
|
35 |
+
response = requests.post(URL, json=body)
|
36 |
+
|
37 |
+
callbackURL = data.get('callbackURL')
|
38 |
+
requests.get(callbackURL)
|
39 |
|
40 |
return response.json()
|
41 |
|
42 |
+
|
43 |
+
# @app.route('/client', methods=['POST'])
|
44 |
+
# def client():
|
45 |
+
# token = request.json.get('token')
|
46 |
+
# data = reqList.get(token)
|
47 |
+
# if not data:
|
48 |
+
# return {}, 400
|
49 |
+
# print(data)
|
50 |
+
# URL = data.get('URL')
|
51 |
+
# postData = data.get('postData')
|
52 |
+
|
53 |
+
# response = requests.post(URL, json=postData)
|
54 |
+
|
55 |
+
# return response.json()
|
56 |
+
|
57 |
if __name__ == "__main__":
|
58 |
app.run(host="0.0.0.0", port=7860)
|