Update app.py
Browse files
app.py
CHANGED
@@ -165,14 +165,20 @@ async def optimize_and_upload(images_urls: list[str] | str, convert: bool = Fals
|
|
165 |
print(f'не удалось удалить файл {images_paths[0].parent}: {e}')
|
166 |
|
167 |
if convert:
|
|
|
168 |
try:
|
169 |
ph = TelegraphAPI()
|
170 |
-
content = '\n\n'.join([f'' for url in new_images_urls])
|
171 |
ph_link = ph.create_page_md('Dall-E 3 картинки', content)
|
172 |
-
return ph_link
|
173 |
except Exception as e:
|
174 |
print(f'не удалось создать страницу в телеграфе: {e}')
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
return new_images_urls
|
177 |
|
178 |
|
@@ -208,3 +214,4 @@ async def optimize_images_endpoint(image_urls: ImageURLs):
|
|
208 |
|
209 |
if __name__ == "__main__":
|
210 |
uvicorn_run(app, host='0.0.0.0', port=7860, timeout_keep_alive=90, log_level='info', use_colors=False)
|
|
|
|
165 |
print(f'не удалось удалить файл {images_paths[0].parent}: {e}')
|
166 |
|
167 |
if convert:
|
168 |
+
content = '\n\n'.join([f'' for url in new_images_urls])
|
169 |
try:
|
170 |
ph = TelegraphAPI()
|
|
|
171 |
ph_link = ph.create_page_md('Dall-E 3 картинки', content)
|
172 |
+
return [ph_link]
|
173 |
except Exception as e:
|
174 |
print(f'не удалось создать страницу в телеграфе: {e}')
|
175 |
+
try:
|
176 |
+
from aiorentry.client import Client as RentryClient
|
177 |
+
async with RentryClient('https://rentry.co') as client:
|
178 |
+
page = await client.new_page(content)
|
179 |
+
return [page.url]
|
180 |
+
except Exception as e:
|
181 |
+
print(f'не удалось создать страницу в rentry: {e}')
|
182 |
return new_images_urls
|
183 |
|
184 |
|
|
|
214 |
|
215 |
if __name__ == "__main__":
|
216 |
uvicorn_run(app, host='0.0.0.0', port=7860, timeout_keep_alive=90, log_level='info', use_colors=False)
|
217 |
+
|