|
from flask import Flask, request |
|
import os, json, uuid |
|
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(uuid.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() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
app.run(host="0.0.0.0", port=7860) |