|
import requests |
|
from flask import Flask, request, jsonify |
|
|
|
app = Flask(__name__) |
|
|
|
|
|
BASE_URL = "https://copilot.microsoft.com/" |
|
|
|
def send_message_to_copilot(message): |
|
url = f"{BASE_URL}api/send-message" |
|
headers = { |
|
"Content-Type": "application/json", |
|
"Authorization": "Bearer YOUR_ACCESS_TOKEN" |
|
} |
|
data = { |
|
"message": message |
|
} |
|
response = requests.post(url, headers=headers, json=data) |
|
return response.json() |
|
|
|
@app.route('/api/send', methods=['POST']) |
|
def send(): |
|
content = request.json |
|
user_message = content.get('message', '') |
|
|
|
|
|
response = send_message_to_copilot(user_message) |
|
|
|
return jsonify(response) |
|
|
|
if __name__ == '__main__': |
|
app.run(debug=True) |
|
|