-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscenario-2.py
55 lines (40 loc) · 1.14 KB
/
scenario-2.py
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
from dotenv import load_dotenv
from flask import Flask, request, jsonify
import vonage
from os import environ as env
# Load environment variables from a .env file:
load_dotenv('.env')
# Load in configuration from environment variables:
VONAGE_APPLICATION_ID = env['VONAGE_APPLICATION_ID']
CONF_NAME = env['CONF_NAME']
STREAM_URL = env['STREAM_URL']
uuid = ""
ncco = [
{
"action": "talk",
"text": "Please wait while we connect you to the conference"
},
{
"action": "conversation",
"name": CONF_NAME
}
]
app = Flask(__name__)
@app.route("/webhooks/answer")
def answer_call():
global uuid, in_conf
# print parameters
print("request.args ", request.args)
uuid = request.args.get('uuid')
print("uuid ", uuid)
return (jsonify(ncco))
@app.route("/webhooks/event", methods=['POST'])
def events():
return ("200")
@app.route("/stream")
def stream():
client = vonage.Client(application_id=VONAGE_APPLICATION_ID, private_key='private.key')
client.voice.send_audio(uuid, stream_url=[STREAM_URL])
return ("200")
if __name__ == '__main__':
app.run(host="localhost", port=9000)