Update app.py
Browse files
app.py
CHANGED
|
@@ -1072,23 +1072,20 @@ async def _download_upscaled_image(upscaled_url: str, cookies_dict: dict) -> tup
|
|
| 1072 |
import traceback
|
| 1073 |
traceback.print_exc()
|
| 1074 |
|
| 1075 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1076 |
final_image_url = download_url
|
| 1077 |
try:
|
| 1078 |
-
print(f"☁️ Fazendo upload da imagem sem marca d'água para https://habulaj-recurve-
|
| 1079 |
-
content_type_for_upload = img_response.headers.get('content-type', 'image/png')
|
| 1080 |
-
filename = f"image_{int(time.time())}.png"
|
| 1081 |
-
if "jpeg" in content_type_for_upload or "jpg" in content_type_for_upload:
|
| 1082 |
-
filename = f"image_{int(time.time())}.jpg"
|
| 1083 |
-
|
| 1084 |
-
files = {
|
| 1085 |
-
'files': (filename, img_content, content_type_for_upload)
|
| 1086 |
-
}
|
| 1087 |
-
data = {
|
| 1088 |
-
'long_duration': 'yes'
|
| 1089 |
-
}
|
| 1090 |
|
| 1091 |
-
upload_response = requests.post(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1092 |
upload_response.raise_for_status()
|
| 1093 |
upload_data = upload_response.json()
|
| 1094 |
|
|
@@ -1102,10 +1099,6 @@ async def _download_upscaled_image(upscaled_url: str, cookies_dict: dict) -> tup
|
|
| 1102 |
print(f"⚠️ Erro ao fazer upload da imagem: {e}")
|
| 1103 |
import traceback
|
| 1104 |
traceback.print_exc()
|
| 1105 |
-
|
| 1106 |
-
# Converter para base64
|
| 1107 |
-
img_base64 = base64.b64encode(img_content).decode('utf-8')
|
| 1108 |
-
content_type = img_response.headers.get('content-type', 'image/png')
|
| 1109 |
|
| 1110 |
print(f"✅ Imagem processada e convertida para base64 ({len(img_base64)} chars)")
|
| 1111 |
|
|
|
|
| 1072 |
import traceback
|
| 1073 |
traceback.print_exc()
|
| 1074 |
|
| 1075 |
+
# Converter para base64
|
| 1076 |
+
img_base64 = base64.b64encode(img_content).decode('utf-8')
|
| 1077 |
+
content_type = img_response.headers.get('content-type', 'image/png')
|
| 1078 |
+
|
| 1079 |
+
# Fazer upload para a API externa (upload(2).py)
|
| 1080 |
final_image_url = download_url
|
| 1081 |
try:
|
| 1082 |
+
print(f"☁️ Fazendo upload da imagem sem marca d'água para https://habulaj-recurve-api.hf.space/upload-image")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1083 |
|
| 1084 |
+
upload_response = requests.post(
|
| 1085 |
+
"https://habulaj-recurve-api.hf.space/upload-image",
|
| 1086 |
+
json={"image_base64": img_base64},
|
| 1087 |
+
timeout=60
|
| 1088 |
+
)
|
| 1089 |
upload_response.raise_for_status()
|
| 1090 |
upload_data = upload_response.json()
|
| 1091 |
|
|
|
|
| 1099 |
print(f"⚠️ Erro ao fazer upload da imagem: {e}")
|
| 1100 |
import traceback
|
| 1101 |
traceback.print_exc()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1102 |
|
| 1103 |
print(f"✅ Imagem processada e convertida para base64 ({len(img_base64)} chars)")
|
| 1104 |
|