File size: 1,227 Bytes
bf00a95 dcdfd1b 074798d 822d179 1bb9b5d 15833f6 074798d ee3e7dd 822d179 ee3e7dd 27407e5 1bb9b5d dcdfd1b 1bb9b5d ee3e7dd 1bb9b5d 4bc235e 1bb9b5d 27407e5 1bb9b5d 0944f4f 1bb9b5d 27407e5 1bb9b5d 27407e5 1bb9b5d 27407e5 4bc235e 1bb9b5d 27407e5 |
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 46 47 48 49 50 51 52 53 54 55 56 57 58 |
from flask import Flask, request
import os, json, uuid.uuid4
import requests
app = Flask(__name__)
secret = os.environ.get("auth")
headers = {'Authorization': os.environ.get("auth")}
res = {}
@app.route('/queue', methods=['POST'])
def queue():
if request.json.get('secret') != secret:
return {}, 400
uuid = str(uuid4())
res[uuid] = request.json
print(res[uuid])
return {'uuid': uuid}, 200
@app.route('/asr', methods=['GET'])
def asr():
uuid = request.args.get('uuid')
data = res.get(uuid)
if not data:
return {}, 400
print(data)
URL = data.get('URL')
body = data.get('body')
response = requests.post(URL, json=body)
callbackURL = data.get('callbackURL')
requests.get(callbackURL)
return response.json()
# @app.route('/client', methods=['POST'])
# def client():
# token = request.json.get('token')
# data = reqList.get(token)
# if not data:
# return {}, 400
# print(data)
# URL = data.get('URL')
# postData = data.get('postData')
# response = requests.post(URL, json=postData)
# return response.json()
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7860) |