yuripeyamashita
commited on
Commit
•
7b910fd
1
Parent(s):
664fe73
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ app = Flask(__name__)
|
|
8 |
secret = os.environ.get("auth")
|
9 |
headers = {'Authorization': os.environ.get("auth")}
|
10 |
|
11 |
-
|
12 |
|
13 |
@app.route('/queue', methods=['POST'])
|
14 |
def queue():
|
@@ -16,31 +16,27 @@ def queue():
|
|
16 |
return {}, 400
|
17 |
|
18 |
uuid = str(uuid4())
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
return {'uuid': uuid}, 200
|
23 |
|
24 |
@app.route('/asr', methods=['GET'])
|
25 |
def asr():
|
26 |
uuid = request.args.get('uuid')
|
27 |
-
data =
|
28 |
if not data:
|
29 |
return {}, 400
|
30 |
-
|
31 |
-
print(data)
|
32 |
-
|
33 |
URL = data.get('URL')
|
34 |
body = data.get('body')
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
print(response)
|
42 |
|
43 |
-
return
|
44 |
|
45 |
|
46 |
# @app.route('/client', methods=['POST'])
|
|
|
8 |
secret = os.environ.get("auth")
|
9 |
headers = {'Authorization': os.environ.get("auth")}
|
10 |
|
11 |
+
res_dict = {}
|
12 |
|
13 |
@app.route('/queue', methods=['POST'])
|
14 |
def queue():
|
|
|
16 |
return {}, 400
|
17 |
|
18 |
uuid = str(uuid4())
|
19 |
+
res_dict[uuid] = request.json
|
20 |
|
21 |
+
return { 'uuid': uuid }, 200
|
|
|
22 |
|
23 |
@app.route('/asr', methods=['GET'])
|
24 |
def asr():
|
25 |
uuid = request.args.get('uuid')
|
26 |
+
data = res_dict.get(uuid)
|
27 |
if not data:
|
28 |
return {}, 400
|
29 |
+
|
|
|
|
|
30 |
URL = data.get('URL')
|
31 |
body = data.get('body')
|
32 |
|
33 |
+
res = requests.post(URL, json=body, headers=headers)
|
34 |
+
if res.status_code == 200:
|
35 |
+
callbackURL = data.get('callbackURL')
|
36 |
+
requests.get(callbackURL)
|
37 |
+
return res.json()
|
|
|
38 |
|
39 |
+
return {'error': '請求失敗'}, 500
|
40 |
|
41 |
|
42 |
# @app.route('/client', methods=['POST'])
|