Dooratre commited on
Commit
d69813f
·
verified ·
1 Parent(s): f1809b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -18
app.py CHANGED
@@ -5,6 +5,7 @@ import os
5
  import uuid
6
  from db import fetch_json_from_github # Import the GitHub JSON fetcher
7
  from qwen import get_qwen_response # Import the Qwen response function
 
8
 
9
  app = Flask(__name__)
10
 
@@ -24,22 +25,9 @@ except Exception as e:
24
  AI_SERVICE_URL = "https://aoamrnuwara.pythonanywhere.com/send-message"
25
  AI_SERVICE_TOKEN = "123400"
26
 
27
- # CDN Upload Configuration
28
- UPLOAD_API_URL = "https://api.braininc.net/api/me/upload/studios"
29
- AUTH_TOKEN = "72ec00483379076f580eb8126f29da802a5140c3"
30
-
31
- def upload_image(file_path):
32
- """Upload image to get CDN URL"""
33
- headers = {"authorization": f"token {AUTH_TOKEN}"}
34
- try:
35
- with open(file_path, "rb") as f:
36
- files = {"file": (os.path.basename(file_path), f, "image/png")}
37
- response = requests.post(UPLOAD_API_URL, headers=headers, files=files)
38
- if response.status_code == 201:
39
- return response.json().get("cdn_url", "")
40
- except Exception as e:
41
- print(f"Upload error: {str(e)}")
42
- return ""
43
 
44
  @app.route("/webhook", methods=["GET"])
45
  def verify_webhook():
@@ -85,8 +73,8 @@ def handle_message():
85
  with open(temp_path, "wb") as f:
86
  f.write(img_response.content)
87
 
88
- # Upload to CDN
89
- cdn_url = upload_image(temp_path)
90
  if cdn_url:
91
  image_cdn_urls.append(cdn_url)
92
  except Exception as e:
 
5
  import uuid
6
  from db import fetch_json_from_github # Import the GitHub JSON fetcher
7
  from qwen import get_qwen_response # Import the Qwen response function
8
+ from upload import upload_image_to_cdn # Import the new upload function
9
 
10
  app = Flask(__name__)
11
 
 
25
  AI_SERVICE_URL = "https://aoamrnuwara.pythonanywhere.com/send-message"
26
  AI_SERVICE_TOKEN = "123400"
27
 
28
+ # Qwen CDN Upload Configuration
29
+ BASE_URL = "https://chat.qwen.ai"
30
+ AUTH_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImRjOGQyYzY4LWZjNmEtNDEwYy05NWZjLWQ5MDBmNTM4ZTMwMiIsImV4cCI6MTc0NjM1OTExMH0.ms8Agbit2ObnTMJyeW_dUbk-tV_ON_dc-RjDKCDLAwA"
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  @app.route("/webhook", methods=["GET"])
33
  def verify_webhook():
 
73
  with open(temp_path, "wb") as f:
74
  f.write(img_response.content)
75
 
76
+ # Upload to Qwen CDN
77
+ cdn_url = upload_image_to_cdn(BASE_URL, AUTH_TOKEN, temp_path)
78
  if cdn_url:
79
  image_cdn_urls.append(cdn_url)
80
  except Exception as e: