Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,22 @@
|
|
1 |
from flask import Flask, request
|
2 |
import requests
|
3 |
import json
|
|
|
4 |
from qwen import get_qwen_response # Import the Qwen response function
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
8 |
-
#
|
9 |
try:
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
PAGE_CREDENTIALS = {}
|
15 |
|
16 |
AI_SERVICE_URL = "https://aoamrnuwara.pythonanywhere.com/send-message"
|
|
|
1 |
from flask import Flask, request
|
2 |
import requests
|
3 |
import json
|
4 |
+
from db import fetch_json_from_github # Import the GitHub JSON fetcher
|
5 |
from qwen import get_qwen_response # Import the Qwen response function
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
|
9 |
+
# Fetch page credentials from GitHub on startup
|
10 |
try:
|
11 |
+
github_response = fetch_json_from_github()
|
12 |
+
if github_response["success"]:
|
13 |
+
PAGE_CREDENTIALS = {page['page_id']: page['page_token'] for page in github_response["data"]["pages"]}
|
14 |
+
print("Successfully loaded page credentials from GitHub.")
|
15 |
+
else:
|
16 |
+
print(f"Error loading page credentials: {github_response['message']}")
|
17 |
+
PAGE_CREDENTIALS = {}
|
18 |
+
except Exception as e:
|
19 |
+
print(f"Unexpected error while fetching credentials: {e}")
|
20 |
PAGE_CREDENTIALS = {}
|
21 |
|
22 |
AI_SERVICE_URL = "https://aoamrnuwara.pythonanywhere.com/send-message"
|