File size: 27,186 Bytes
503d684 044b15a 1c8b68d 044b15a 2218121 044b15a 2ba4b46 f043b3f 43305eb 8424f41 d57a882 f043b3f bff639b 1c8b68d bff639b 0f7a742 1c8b68d bff639b 2f3eee0 2ba4b46 1b459b7 2ba4b46 1b459b7 503d684 af3ffbb 9419c65 fd225e2 4f7d7bc af3ffbb fd225e2 4f7d7bc af3ffbb 4f7d7bc af3ffbb 4f7d7bc fd225e2 4f7d7bc 983b7ef af3ffbb 4f7d7bc af3ffbb ce9e1ca 4f7d7bc 983b7ef 4f7d7bc af3ffbb 4f7d7bc af3ffbb 4f7d7bc af3ffbb 4f7d7bc af3ffbb fd225e2 9419c65 4f7d7bc c1e283b 4f7d7bc af3ffbb 4f7d7bc af3ffbb 4f7d7bc af3ffbb 4f7d7bc af3ffbb 4f7d7bc af3ffbb 9419c65 b2de22f 044b15a 97952c9 1c8b68d 97952c9 1b459b7 983b7ef 1b459b7 2218121 044b15a 2d780e7 044b15a fd225e2 2218121 8985d12 044b15a fd225e2 044b15a bff639b 044b15a fd225e2 bff639b fd225e2 044b15a 983b7ef 1c8b68d 2f3eee0 044b15a 1982de9 2f3eee0 9419c65 983b7ef 7b356ed 983b7ef 2f3eee0 bff639b 1e9923c bff639b 1e9923c bff639b 1e9923c bff639b 1e9923c bff639b 8424f41 e6f7f6e 1e9923c e6f7f6e bff639b 1e9923c bff639b 1e9923c bff639b 9419c65 1e9923c 9419c65 1e9923c 983b7ef 9419c65 1e9923c 9419c65 044b15a 43305eb 8985d12 43305eb 8a10cf7 43305eb 983b7ef 1c8b68d 43305eb 983b7ef 43305eb 983b7ef 43305eb 1982de9 044b15a 503d684 044b15a fd225e2 044b15a fd225e2 044b15a fef6019 1e9923c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
from fastapi import FastAPI, File, UploadFile, Request, Form
from fastapi.responses import HTMLResponse, RedirectResponse, StreamingResponse
from typing import List, Optional
import requests
import asyncio
import uuid
from datetime import datetime
import mimetypes
import httpx
import io
import zipfile
import math
app = FastAPI()
DENO_API_URL = "https://dataerrr99.deno.dev"
async def save_album_to_db(album_name: str, album_id: str, files: List[dict], is_private: bool = False):
async with httpx.AsyncClient() as client:
try:
response = await client.post(DENO_API_URL, json={
"albumName": album_name,
"albumLink": album_id,
"files": files,
"isPrivate": is_private,
"createdAt": datetime.now().isoformat()
})
return response.json()
except Exception as e:
print(f"Error saving to DB: {str(e)}")
return None
async def get_albums_from_db():
async with httpx.AsyncClient() as client:
try:
response = await client.get(DENO_API_URL)
return response.json()
except Exception as e:
print(f"Error fetching from DB: {str(e)}")
return {"data": []}
async def get_album_from_db(album_id: str):
async with httpx.AsyncClient() as client:
try:
response = await client.get(f"{DENO_API_URL}/{album_id}")
return response.json()
except Exception as e:
print(f"Error fetching album from DB: {str(e)}")
return None
def get_file_type(filename):
mime_type, _ = mimetypes.guess_type(filename)
if mime_type:
if mime_type.startswith('image/'):
return 'image'
elif mime_type.startswith('video/'):
return 'video'
elif mime_type.startswith('audio/'):
return 'audio'
return 'other'
def is_allowed_file_type(filename):
allowed_types = ['image', 'video', 'audio', 'application/zip']
mime_type, _ = mimetypes.guess_type(filename)
return mime_type and any(mime_type.startswith(t) for t in allowed_types)
@app.get("/", response_class=HTMLResponse)
async def index():
return """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Upload</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f5;
color: #333;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
padding: 30px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
h1 {
font-size: 2.5em;
margin-bottom: 20px;
color: #007bff;
}
h2 {
font-size: 1.8em;
margin-top: 30px;
margin-bottom: 15px;
color: #333;
}
.upload-form {
margin-top: 20px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
font-weight: 500;
margin-bottom: 8px;
}
.form-group input[type="text"],
.form-group input[type="file"] {
width: 100%;
padding: 12px;
border: 2px solid #ddd;
border-radius: 8px;
font-size: 1em;
transition: border-color 0.3s ease;
}
.form-group input[type="text"]:focus,
.form-group input[type="file"]:focus {
border-color: #007bff;
outline: none;
}
.file-input {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
border: 2px dashed #ddd;
text-align: center;
cursor: pointer;
transition: background 0.3s ease, border-color 0.3s ease;
}
.file-input:hover {
background: #e9ecef;
border-color: #007bff;
}
.file-input.dragover {
background: #e9ecef;
border-color: #007bff;
}
.file-input input {
display: none;
}
.file-input label {
font-size: 1.1em;
color: #666;
cursor: pointer;
}
.private-checkbox {
display: flex;
align-items: center;
gap: 10px;
margin-top: 20px;
}
.private-checkbox input {
width: 18px;
height: 18px;
cursor: pointer;
}
.private-checkbox label {
font-size: 1em;
color: #666;
}
.progress-bar {
width: 100%;
height: 12px;
background: #e9ecef;
border-radius: 6px;
margin-top: 20px;
overflow: hidden;
display: none;
}
.progress-bar-inner {
height: 100%;
background: #007bff;
width: 0%;
border-radius: 6px;
transition: width 0.3s ease;
}
.button {
display: inline-block;
padding: 12px 24px;
background: #007bff;
color: white;
border: none;
border-radius: 8px;
font-size: 1em;
cursor: pointer;
transition: background 0.3s ease;
margin-top: 20px;
}
.button:hover {
background: #0056b3;
}
.button:disabled {
background: #ccc;
cursor: not-allowed;
}
.upload-status {
margin-top: 20px;
font-size: 0.9em;
color: #666;
}
.search-form {
margin-top: 30px;
}
.search-form input[type="text"] {
width: calc(100% - 100px);
padding: 12px;
border: 2px solid #ddd;
border-radius: 8px;
font-size: 1em;
transition: border-color 0.3s ease;
}
.search-form input[type="text"]:focus {
border-color: #007bff;
outline: none;
}
.search-form button {
padding: 12px 24px;
background: #28a745;
color: white;
border: none;
border-radius: 8px;
font-size: 1em;
cursor: pointer;
transition: background 0.3s ease;
}
.search-form button:hover {
background: #218838;
}
@media (max-width: 768px) {
.container {
padding: 20px;
}
h1 {
font-size: 2em;
}
h2 {
font-size: 1.5em;
}
.button {
width: 100%;
margin-top: 15px;
}
.search-form input[type="text"] {
width: calc(100% - 90px);
}
}
</style>
</head>
<body>
<div class="container">
<h1>bing bong</h1>
<form class="upload-form" action="/album/create" method="post" enctype="multipart/form-data" onsubmit="showProgressBar()">
<div class="form-group">
<label for="album_name">Album Name</label>
<input type="text" id="album_name" name="album_name" placeholder="Enter album name" required>
</div>
<div class="form-group">
<div class="file-input" id="fileInput" ondragover="handleDragOver(event)" ondrop="handleDrop(event)">
<input type="file" id="files" name="files" multiple required>
<label for="files">Drag & drop files here or click to upload</label>
</div>
</div>
<div class="private-checkbox">
<input type="checkbox" id="is_private" name="is_private">
<label for="is_private">Make this album private (exclude from search)</label>
</div>
<div class="progress-bar" id="progressBar">
<div class="progress-bar-inner" id="progressBarInner"></div>
</div>
<button type="submit" class="button" id="uploadButton">Create Album</button>
<div class="upload-status" id="uploadStatus"></div>
</form>
<h2>Search Albums</h2>
<form class="search-form" action="/search" method="get">
<input type="text" name="query" placeholder="Search by album name..." required>
<button type="submit">Search</button>
</form>
</div>
<script>
function showProgressBar() {
const progressBar = document.getElementById('progressBar');
const progressBarInner = document.getElementById('progressBarInner');
const uploadButton = document.getElementById('uploadButton');
const uploadStatus = document.getElementById('uploadStatus');
progressBar.style.display = 'block';
uploadButton.disabled = true;
uploadButton.textContent = 'Uploading...';
uploadStatus.textContent = 'Starting upload...';
let progress = 0;
const interval = setInterval(() => {
progress += 1;
progressBarInner.style.width = progress + '%';
if (progress >= 90) {
clearInterval(interval);
}
}, 30);
}
function handleDragOver(event) {
event.preventDefault();
const fileInput = document.getElementById('fileInput');
fileInput.classList.add('dragover');
}
function handleDrop(event) {
event.preventDefault();
const fileInput = document.getElementById('fileInput');
fileInput.classList.remove('dragover');
const files = event.dataTransfer.files;
document.getElementById('files').files = files;
updateFileLabel(files);
}
function updateFileLabel(files) {
const label = document.querySelector('.file-input label');
if (files.length > 0) {
label.textContent = `${files.length} file(s) selected`;
} else {
label.textContent = 'Drag & drop files here or click to upload';
}
}
document.getElementById('files').addEventListener('change', (event) => {
updateFileLabel(event.target.files);
});
</script>
</body>
</html>
"""
@app.post("/album/create")
async def create_album(
request: Request,
album_name: str = Form(...),
files: List[UploadFile] = File(...),
is_private: Optional[bool] = Form(False)
):
for file in files:
if not is_allowed_file_type(file.filename):
return HTMLResponse(content=f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Error</title>
</head>
<body>
<h1>Error: Invalid File Type</h1>
<p>The file '{file.filename}' is not allowed. Please upload it using the <a href="https://albumup-up1.hf.space/">Single File Upload</a>.</p>
<a href="/" class="button">← Back to Home</a>
</body>
</html>
""", status_code=400)
album_id = str(uuid.uuid4())
album_files = []
cookies = await get_cookies()
total_files = len(files)
uploaded_files = 0
for file in files:
file_content = await file.read()
upload_result = await initiate_upload(cookies, file.filename, file.content_type)
if upload_result and 'upload_url' in upload_result:
upload_success = await retry_upload(upload_result['upload_url'], file_content, file.content_type)
if upload_success:
serving_path = upload_result['serving_url'].split('/pbxt/')[1]
album_files.append({
'filename': file.filename,
'path': serving_path,
'content_type': file.content_type,
'uploaded_at': datetime.now().isoformat()
})
uploaded_files += 1
progress = math.floor((uploaded_files / total_files) * 100)
print(f"Upload Progress: {progress}%")
# Save to Deno KV database
await save_album_to_db(album_name, album_id, album_files, is_private)
base_url = str(request.base_url).rstrip('/')
return RedirectResponse(url=f"{base_url}/album/{album_id}", status_code=303)
@app.get("/album/{album_id}", response_class=HTMLResponse)
async def view_album(album_id: str):
album = await get_album_from_db(album_id)
if not album or 'files' not in album:
return "Album not found or invalid data", 404
file_list_html = ""
for file in album['files']:
file_url = f"/upload/{file['path']}"
file_type = get_file_type(file['filename'])
download_url = f"{file_url}?download=true"
preview_html = ""
if file_type == 'image':
preview_html = f"""
<div class="preview-container" onclick="openModal('{file_url}')">
<img src="{file_url}" alt="{file['filename']}" loading="lazy">
</div>
"""
elif file_type == 'video':
preview_html = f"""
<div class="preview-container" onclick="openModal('{file_url}')">
<video>
<source src="{file_url}" type="{file['content_type']}">
</video>
<div class="play-icon">▶</div>
</div>
"""
else:
preview_html = f"""
<div class="preview-container">
<div class="file-icon">
<svg viewBox="0 0 24 24">
<path fill="currentColor" d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z"/>
</svg>
</div>
</div>
"""
file_list_html += f"""
<div class="file-card">
{preview_html}
<div class="file-info">
<span class="filename">{file['filename']}</span>
<div class="actions">
<a href="{file_url}" target="_blank" class="action-btn view">View</a>
<a href="{download_url}" class="action-btn download">Download</a>
</div>
</div>
</div>
"""
return f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{album['albumName']}</title>
<style>
body {{
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f5;
}}
.album-header {{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
flex-wrap: wrap;
gap: 15px;
}}
.grid-container {{
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 20px;
padding: 10px;
}}
.file-card {{
background: white;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
overflow: hidden;
transition: transform 0.2s;
}}
.file-card:hover {{
transform: translateY(-2px);
}}
.preview-container {{
position: relative;
background: #f8f9fa;
cursor: pointer;
aspect-ratio: 1;
}}
.preview-container img,
.preview-container video {{
width: 100%;
height: 100%;
object-fit: cover;
}}
.file-info {{
padding: 15px;
}}
.filename {{
display: block;
font-size: 0.9em;
color: #333;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 10px;
}}
.actions {{
display: flex;
gap: 8px;
}}
.action-btn {{
flex: 1;
padding: 8px 12px;
text-align: center;
border-radius: 6px;
font-size: 0.85em;
text-decoration: none;
transition: all 0.2s;
}}
.view {{
background: #007bff;
color: white;
}}
.view:hover {{
background: #0056b3;
}}
.download {{
background: #28a745;
color: white;
}}
.download:hover {{
background: #218838;
}}
.play-icon {{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 2.5em;
color: white;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
opacity: 0.9;
}}
.file-icon {{
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
color: #666;
}}
.file-icon svg {{
width: 50%;
height: 50%;
}}
/* Modal styles */
.modal {{
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.9);
justify-content: center;
align-items: center;
}}
.modal-content {{
max-width: 90%;
max-height: 90%;
background: black;
}}
.modal-media {{
max-width: 100%;
max-height: 80vh;
object-fit: contain;
}}
.close-modal {{
position: absolute;
top: 20px;
right: 30px;
color: white;
font-size: 40px;
cursor: pointer;
z-index: 1001;
}}
@media (max-width: 768px) {{
.grid-container {{
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}}
.album-header {{
flex-direction: column;
align-items: flex-start;
}}
}}
</style>
</head>
<body>
<div class="album-header">
<h1>{album['albumName']}</h1>
<a href="/album/{album_id}/download" class="download-all-btn">Download All as ZIP</a>
</div>
<div class="grid-container">
{file_list_html}
</div>
<div id="modal" class="modal" onclick="closeModal()">
<span class="close-modal">×</span>
<div class="modal-content">
<img id="modal-media" class="modal-media" src="" alt="">
<video id="modal-video" class="modal-media" controls style="display: none;"></video>
</div>
</div>
<script>
function openModal(url) {{
const modal = document.getElementById('modal');
const imgModal = document.getElementById('modal-media');
const videoModal = document.getElementById('modal-video');
if (url.includes('.mp4') || url.includes('.webm')) {{
videoModal.style.display = 'block';
imgModal.style.display = 'none';
videoModal.src = url;
}} else {{
imgModal.style.display = 'block';
videoModal.style.display = 'none';
imgModal.src = url;
}}
modal.style.display = 'flex';
}}
function closeModal() {{
document.getElementById('modal').style.display = 'none';
document.getElementById('modal-video').pause();
}}
// Close modal when clicking outside content
window.onclick = function(event) {{
const modal = document.getElementById('modal');
if (event.target === modal) {{
closeModal();
}}
}}
</script>
</body>
</html>
"""
@app.get("/album/{album_id}/download")
async def download_album(album_id: str):
album = await get_album_from_db(album_id)
if not album or 'files' not in album:
return {"error": "Album not found or invalid data"}, 404
zip_buffer = io.BytesIO()
with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:
for file in album['files']:
response = requests.get(f"https://replicate.delivery/pbxt/{file['path']}")
zip_file.writestr(file['filename'], response.content)
zip_buffer.seek(0)
return StreamingResponse(
io.BytesIO(zip_buffer.getvalue()),
media_type="application/zip",
headers={
"Content-Type": "application/zip",
"Content-Disposition": f"attachment; filename={album['albumName']}.zip"
}
)
@app.get("/search", response_class=HTMLResponse)
async def search_albums(query: str):
db_albums = await get_albums_from_db()
# Exclude private albums from search results
matching_albums = [
album for album in db_albums['data']
if query.lower() in album.get('albumName', '').lower() and not album.get('isPrivate', False)
]
results_html = ""
for album in matching_albums:
results_html += f"""
<div class="album-item">
<h3>{album['albumName']}</h3>
<p>Created: {album['createdAt']}</p>
<p>Files: {len(album['files'])}</p>
<a href="/album/{album['albumLink']}" class="button">View Album</a>
</div>
"""
return f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Results</title>
</head>
<body>
<h1>Search Results</h1>
<p>Found {len(matching_albums)} albums for "{query}"</p>
<div class="search-results">
{results_html}
</div>
<a href="/" class="button">← Back to Home</a>
</body>
</html>
"""
@app.get("/upload/{path:path}")
async def handle_stream(path: str, request: Request):
original_url = f'https://replicate.delivery/pbxt/{path}'
range_header = request.headers.get('Range')
headers = {'Range': range_header} if range_header else {}
response = requests.get(original_url, headers=headers, stream=True)
def generate():
for chunk in response.iter_content(chunk_size=8192):
yield chunk
headers = dict(response.headers)
headers['Access-Control-Allow-Origin'] = '*'
return StreamingResponse(generate(), headers=headers, status_code=response.status_code)
async def get_cookies():
try:
response = requests.get('https://replicate.com/levelsio/neon-tokyo', headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
})
return dict(response.cookies)
except Exception:
return {}
async def initiate_upload(cookies, filename, content_type):
url = f"https://replicate.com/api/upload/{filename}?content_type={content_type}"
headers = {
'X-CSRFToken': cookies['csrftoken'],
'Referer': 'https://replicate.com/levelsio/neon-tokyo',
'Origin': 'https://replicate.com'
}
response = requests.post(url, cookies=cookies, headers=headers)
return response.json()
async def retry_upload(upload_url, file_content, content_type, max_retries=5):
delay = 1
for _ in range(max_retries):
try:
response = requests.put(upload_url, data=file_content, headers={'Content-Type': content_type})
if response.status_code == 200:
return True
except Exception:
pass
await asyncio.sleep(delay)
delay *= 2
return False
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000) |