import logging
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/api/v1/skill', methods=['POST'])
def skill():
request_json = request.json
if 'request' in request_json:
command = request_json['request']['command']
if 'Включи аудио стрим' in command:
response_text = 'Включаю аудио стрим'
url = 'http://you.site/stream.mp3'
return jsonify({
"version": request_json['version'],
"response": {
"text": response_text,
"tts": response_text,
"buttons": [],
"end_session": False
},
"session": request_json['session'],
"user_id": request_json['session']['user_id'],
"audio": {
"url": url
}
})
return jsonify({'status': 'error'})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)