Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ HTML_CONTENT = """
|
|
| 14 |
<title>Radd PRO Uploader</title>
|
| 15 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 16 |
<style>
|
| 17 |
-
/* Global Styles
|
| 18 |
body {
|
| 19 |
font-family: 'Poppins', sans-serif;
|
| 20 |
background-color: #121212;
|
|
@@ -24,7 +24,7 @@ HTML_CONTENT = """
|
|
| 24 |
overflow: hidden;
|
| 25 |
}
|
| 26 |
|
| 27 |
-
|
| 28 |
body::before {
|
| 29 |
content: "";
|
| 30 |
position: fixed;
|
|
@@ -52,13 +52,6 @@ HTML_CONTENT = """
|
|
| 52 |
100% { transform: translate(5%, 0); }
|
| 53 |
}
|
| 54 |
|
| 55 |
-
/ Glow Animation /
|
| 56 |
-
@keyframes glowAnimation {
|
| 57 |
-
0% { box-shadow: 0 0 5px rgba(0, 150, 255, 0.3); }
|
| 58 |
-
50% { box-shadow: 0 0 20px rgba(0, 150, 255, 0.6); }
|
| 59 |
-
100% { box-shadow: 0 0 5px rgba(0, 150, 255, 0.3); }
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
.container {
|
| 63 |
position: relative;
|
| 64 |
max-width: 450px;
|
|
@@ -79,13 +72,13 @@ HTML_CONTENT = """
|
|
| 79 |
text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
|
| 80 |
}
|
| 81 |
|
| 82 |
-
|
| 83 |
.btn {
|
| 84 |
display: inline-block;
|
| 85 |
position: relative;
|
| 86 |
-
padding:
|
| 87 |
-
margin: 0.
|
| 88 |
-
font-size:
|
| 89 |
font-weight: 600;
|
| 90 |
color: #ffffff;
|
| 91 |
background-color: #2a2a2a;
|
|
@@ -99,32 +92,67 @@ HTML_CONTENT = """
|
|
| 99 |
|
| 100 |
.btn:hover {
|
| 101 |
color: #ffffff;
|
| 102 |
-
box-shadow: 0 0 15px rgba(0,
|
| 103 |
}
|
| 104 |
|
| 105 |
.btn:hover::before {
|
| 106 |
content: '';
|
| 107 |
position: absolute;
|
| 108 |
inset: -10px;
|
| 109 |
-
background: radial-gradient(circle at center, rgba(0,
|
| 110 |
filter: blur(20px);
|
| 111 |
animation: glowAnimation 2s infinite;
|
| 112 |
z-index: -1;
|
| 113 |
pointer-events: none;
|
| 114 |
}
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
.btn:active {
|
| 117 |
transform: scale(0.98);
|
| 118 |
}
|
| 119 |
|
| 120 |
-
|
| 121 |
-
.
|
| 122 |
-
padding:
|
| 123 |
-
font-size: 0.
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
}
|
| 126 |
|
| 127 |
-
|
| 128 |
.drop-zone {
|
| 129 |
position: relative;
|
| 130 |
padding: 20px;
|
|
@@ -134,27 +162,23 @@ HTML_CONTENT = """
|
|
| 134 |
cursor: pointer;
|
| 135 |
transition: all 0.3s ease;
|
| 136 |
background: rgba(255, 255, 255, 0.05);
|
| 137 |
-
overflow: hidden;
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
.drop-zone::before {
|
| 141 |
-
content: '';
|
| 142 |
-
position: absolute;
|
| 143 |
-
inset: 0;
|
| 144 |
-
background: none;
|
| 145 |
-
transition: background 0.3s ease;
|
| 146 |
-
pointer-events: none;
|
| 147 |
-
}
|
| 148 |
-
|
| 149 |
-
.drop-zone:hover::before {
|
| 150 |
-
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAQAAACM/9unAAAACXBIWXMAAAsTAAALEwEAmpwYAAABF0lEQVR4nO3YMRLCQBRE0clsYgxZwwq7oLGxAgp2AtbsqQZsYgEG0wEWc/LSZnb9HcMjR8fHvEKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgsK8tJOq9fzs7vlkNlWvf5ELi+20t5k2VSL7p/iHJ5Rz5ynOhU7rQ4pUi+6b4hyeUc+cpzoVO60OkV7rQ4pUi+6b4hxenu+en4rQAOkaks/eJegGaUfOHI+nRvQCND1w2J9yf8C2KZwNjkeUsAKRa7Nz50tQAokVbO/U6AaiWjl5wd6kQAOke8Xpx3JgTQKVq7Heh0ADpFvF6cd0kE0Claux3odAA6RfxenHc+BNCpWrsd6HQAOkX8Xpx3PgTQqVq7Heh0ADpF/F6cdz4E0KlarjdI/cR1FBQUGBgYGBgYGBgYG/AT4AIHph6aQGU7oAAAAASUVORK5CYII=') repeat;
|
| 151 |
-
animation: grain 8s steps(10) infinite;
|
| 152 |
-
opacity: 0.3;
|
| 153 |
}
|
| 154 |
|
| 155 |
.drop-zone:hover, .drop-zone.drag-over {
|
| 156 |
border-color: #ffffff;
|
| 157 |
background: rgba(255, 255, 255, 0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
}
|
| 159 |
|
| 160 |
.file-input {
|
|
@@ -167,7 +191,7 @@ HTML_CONTENT = """
|
|
| 167 |
color: #aaa;
|
| 168 |
}
|
| 169 |
|
| 170 |
-
|
| 171 |
.progress-container {
|
| 172 |
display: none;
|
| 173 |
margin-top: 1.5rem;
|
|
@@ -189,7 +213,7 @@ HTML_CONTENT = """
|
|
| 189 |
transition: width 0.3s ease;
|
| 190 |
}
|
| 191 |
|
| 192 |
-
|
| 193 |
.loading-spinner {
|
| 194 |
display: none;
|
| 195 |
width: 40px;
|
|
@@ -206,7 +230,7 @@ HTML_CONTENT = """
|
|
| 206 |
100% { transform: rotate(360deg); }
|
| 207 |
}
|
| 208 |
|
| 209 |
-
|
| 210 |
.result-container {
|
| 211 |
display: none;
|
| 212 |
margin-top: 1.5rem;
|
|
@@ -224,14 +248,14 @@ HTML_CONTENT = """
|
|
| 224 |
text-decoration: underline;
|
| 225 |
}
|
| 226 |
|
| 227 |
-
|
| 228 |
.file-types {
|
| 229 |
margin-top: 2rem;
|
| 230 |
font-size: 0.8rem;
|
| 231 |
color: #aaa;
|
| 232 |
}
|
| 233 |
|
| 234 |
-
|
| 235 |
.modal {
|
| 236 |
display: none;
|
| 237 |
position: fixed;
|
|
@@ -295,7 +319,7 @@ HTML_CONTENT = """
|
|
| 295 |
margin-right: 10px;
|
| 296 |
}
|
| 297 |
|
| 298 |
-
|
| 299 |
@media (max-width: 480px) {
|
| 300 |
.container {
|
| 301 |
padding: 2rem 1rem;
|
|
@@ -322,7 +346,7 @@ HTML_CONTENT = """
|
|
| 322 |
<h1>Radd PRO Uploader</h1>
|
| 323 |
<form id="uploadForm">
|
| 324 |
<div id="dropZone" class="drop-zone">
|
| 325 |
-
<input type="file" name="file" id="file" class="file-input" accept=".zip,.mp4,.txt,.mp3,image
|
| 326 |
<label for="file" class="btn">Choose File</label>
|
| 327 |
<p>or drag and drop file here/paste image</p>
|
| 328 |
</div>
|
|
@@ -339,12 +363,12 @@ HTML_CONTENT = """
|
|
| 339 |
|
| 340 |
<div id="embedModal" class="modal">
|
| 341 |
<div class="modal-content">
|
| 342 |
-
<span class="close"
|
| 343 |
<h2>Embed Video Link</h2>
|
| 344 |
<p>Copy the following link to embed the video:</p>
|
| 345 |
<div class="embed-container">
|
| 346 |
<input type="text" id="embedLink" readonly>
|
| 347 |
-
<button onclick="copyEmbedLink()" class="btn copy-embed-btn">Copy</button>
|
| 348 |
</div>
|
| 349 |
</div>
|
| 350 |
</div>
|
|
@@ -370,10 +394,6 @@ HTML_CONTENT = """
|
|
| 370 |
}
|
| 371 |
});
|
| 372 |
|
| 373 |
-
dropZone.addEventListener('click', () => {
|
| 374 |
-
fileInput.click();
|
| 375 |
-
});
|
| 376 |
-
|
| 377 |
dropZone.addEventListener('dragover', (e) => {
|
| 378 |
e.preventDefault();
|
| 379 |
dropZone.classList.add('drag-over');
|
|
@@ -492,13 +512,13 @@ HTML_CONTENT = """
|
|
| 492 |
|
| 493 |
const link = document.createElement('a');
|
| 494 |
link.href = url;
|
| 495 |
-
link.textContent = View ${fileName}
|
| 496 |
link.className = 'result-link';
|
| 497 |
link.target = '_blank';
|
| 498 |
|
| 499 |
const copyBtn = document.createElement('button');
|
| 500 |
copyBtn.textContent = 'Copy Link';
|
| 501 |
-
copyBtn.className = 'btn copy-btn';
|
| 502 |
copyBtn.onclick = () => {
|
| 503 |
navigator.clipboard.writeText(window.location.origin + url).then(() => {
|
| 504 |
alert('Link copied to clipboard!');
|
|
@@ -511,7 +531,7 @@ HTML_CONTENT = """
|
|
| 511 |
if (fileName.toLowerCase().endsWith('.mp4')) {
|
| 512 |
const embedBtn = document.createElement('button');
|
| 513 |
embedBtn.textContent = 'Embed Video for Discord';
|
| 514 |
-
embedBtn.className = 'btn embed-btn';
|
| 515 |
embedBtn.onclick = () => {
|
| 516 |
showEmbedModal(url);
|
| 517 |
};
|
|
@@ -523,7 +543,7 @@ HTML_CONTENT = """
|
|
| 523 |
}
|
| 524 |
|
| 525 |
function showEmbedModal(url) {
|
| 526 |
-
const embedUrl =
|
| 527 |
embedLinkInput.value = embedUrl;
|
| 528 |
modal.style.display = "block";
|
| 529 |
}
|
|
@@ -578,7 +598,7 @@ async def handle_video_stream(path: str, request: Request):
|
|
| 578 |
yield chunk
|
| 579 |
|
| 580 |
headers = dict(response.headers)
|
| 581 |
-
headers['Access-Control-Allow-Origin'] = ''
|
| 582 |
headers['Content-Disposition'] = 'inline'
|
| 583 |
|
| 584 |
if response.status_code == 206:
|
|
@@ -642,10 +662,10 @@ async def initiate_upload(cookies: Dict[str, str], filename: str, content_type:
|
|
| 642 |
try:
|
| 643 |
response = requests.post(url, cookies=cookies, headers={
|
| 644 |
'X-CSRFToken': cookies.get('csrftoken'),
|
| 645 |
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
|
| 646 |
'Referer': 'https://replicate.com/levelsio/neon-tokyo',
|
| 647 |
'Origin': 'https://replicate.com',
|
| 648 |
-
'Accept': '
|
| 649 |
'Accept-Language': 'en-US,en;q=0.5',
|
| 650 |
'Accept-Encoding': 'identity',
|
| 651 |
'Sec-Fetch-Dest': 'empty',
|
|
|
|
| 14 |
<title>Radd PRO Uploader</title>
|
| 15 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
|
| 16 |
<style>
|
| 17 |
+
/* Global Styles */
|
| 18 |
body {
|
| 19 |
font-family: 'Poppins', sans-serif;
|
| 20 |
background-color: #121212;
|
|
|
|
| 24 |
overflow: hidden;
|
| 25 |
}
|
| 26 |
|
| 27 |
+
/* Moving Grainy Background */
|
| 28 |
body::before {
|
| 29 |
content: "";
|
| 30 |
position: fixed;
|
|
|
|
| 52 |
100% { transform: translate(5%, 0); }
|
| 53 |
}
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
.container {
|
| 56 |
position: relative;
|
| 57 |
max-width: 450px;
|
|
|
|
| 72 |
text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
|
| 73 |
}
|
| 74 |
|
| 75 |
+
/* Buttons */
|
| 76 |
.btn {
|
| 77 |
display: inline-block;
|
| 78 |
position: relative;
|
| 79 |
+
padding: 12px 24px;
|
| 80 |
+
margin: 0.5rem;
|
| 81 |
+
font-size: 1rem;
|
| 82 |
font-weight: 600;
|
| 83 |
color: #ffffff;
|
| 84 |
background-color: #2a2a2a;
|
|
|
|
| 92 |
|
| 93 |
.btn:hover {
|
| 94 |
color: #ffffff;
|
| 95 |
+
box-shadow: 0 0 15px rgba(0, 122, 255, 0.5);
|
| 96 |
}
|
| 97 |
|
| 98 |
.btn:hover::before {
|
| 99 |
content: '';
|
| 100 |
position: absolute;
|
| 101 |
inset: -10px;
|
| 102 |
+
background: radial-gradient(circle at center, rgba(0,122,255,0.2), transparent);
|
| 103 |
filter: blur(20px);
|
| 104 |
animation: glowAnimation 2s infinite;
|
| 105 |
z-index: -1;
|
| 106 |
pointer-events: none;
|
| 107 |
}
|
| 108 |
|
| 109 |
+
@keyframes glowAnimation {
|
| 110 |
+
0% { transform: scale(0.8); }
|
| 111 |
+
50% { transform: scale(1.2); }
|
| 112 |
+
100% { transform: scale(0.8); }
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
.btn:active {
|
| 116 |
transform: scale(0.98);
|
| 117 |
}
|
| 118 |
|
| 119 |
+
/* Small Buttons */
|
| 120 |
+
.small-btn {
|
| 121 |
+
padding: 8px 16px;
|
| 122 |
+
font-size: 0.9rem;
|
| 123 |
+
font-weight: 500;
|
| 124 |
+
background-color: #2a2a2a;
|
| 125 |
+
color: #ffffff;
|
| 126 |
+
border: none;
|
| 127 |
+
border-radius: 5px;
|
| 128 |
+
cursor: pointer;
|
| 129 |
+
transition: color 0.3s ease, box-shadow 0.3s ease;
|
| 130 |
+
position: relative;
|
| 131 |
+
overflow: hidden;
|
| 132 |
+
z-index: 1;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.small-btn:hover {
|
| 136 |
+
color: #ffffff;
|
| 137 |
+
box-shadow: 0 0 10px rgba(0, 122, 255, 0.5);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
.small-btn:hover::before {
|
| 141 |
+
content: '';
|
| 142 |
+
position: absolute;
|
| 143 |
+
inset: -10px;
|
| 144 |
+
background: radial-gradient(circle at center, rgba(0,122,255,0.2), transparent);
|
| 145 |
+
filter: blur(15px);
|
| 146 |
+
animation: glowAnimation 2s infinite;
|
| 147 |
+
z-index: -1;
|
| 148 |
+
pointer-events: none;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.small-btn:active {
|
| 152 |
+
transform: scale(0.98);
|
| 153 |
}
|
| 154 |
|
| 155 |
+
/* Drop Zone */
|
| 156 |
.drop-zone {
|
| 157 |
position: relative;
|
| 158 |
padding: 20px;
|
|
|
|
| 162 |
cursor: pointer;
|
| 163 |
transition: all 0.3s ease;
|
| 164 |
background: rgba(255, 255, 255, 0.05);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
|
| 167 |
.drop-zone:hover, .drop-zone.drag-over {
|
| 168 |
border-color: #ffffff;
|
| 169 |
background: rgba(255, 255, 255, 0.1);
|
| 170 |
+
position: relative;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.drop-zone:hover::before {
|
| 174 |
+
content: '';
|
| 175 |
+
position: absolute;
|
| 176 |
+
inset: -10px;
|
| 177 |
+
background: radial-gradient(circle at center, rgba(0,122,255,0.2), transparent);
|
| 178 |
+
filter: blur(20px);
|
| 179 |
+
animation: glowAnimation 2s infinite;
|
| 180 |
+
z-index: -1;
|
| 181 |
+
pointer-events: none;
|
| 182 |
}
|
| 183 |
|
| 184 |
.file-input {
|
|
|
|
| 191 |
color: #aaa;
|
| 192 |
}
|
| 193 |
|
| 194 |
+
/* Progress Bar */
|
| 195 |
.progress-container {
|
| 196 |
display: none;
|
| 197 |
margin-top: 1.5rem;
|
|
|
|
| 213 |
transition: width 0.3s ease;
|
| 214 |
}
|
| 215 |
|
| 216 |
+
/* Loading Spinner */
|
| 217 |
.loading-spinner {
|
| 218 |
display: none;
|
| 219 |
width: 40px;
|
|
|
|
| 230 |
100% { transform: rotate(360deg); }
|
| 231 |
}
|
| 232 |
|
| 233 |
+
/* Result Container */
|
| 234 |
.result-container {
|
| 235 |
display: none;
|
| 236 |
margin-top: 1.5rem;
|
|
|
|
| 248 |
text-decoration: underline;
|
| 249 |
}
|
| 250 |
|
| 251 |
+
/* File Types */
|
| 252 |
.file-types {
|
| 253 |
margin-top: 2rem;
|
| 254 |
font-size: 0.8rem;
|
| 255 |
color: #aaa;
|
| 256 |
}
|
| 257 |
|
| 258 |
+
/* Modal Styles */
|
| 259 |
.modal {
|
| 260 |
display: none;
|
| 261 |
position: fixed;
|
|
|
|
| 319 |
margin-right: 10px;
|
| 320 |
}
|
| 321 |
|
| 322 |
+
/* Media Queries */
|
| 323 |
@media (max-width: 480px) {
|
| 324 |
.container {
|
| 325 |
padding: 2rem 1rem;
|
|
|
|
| 346 |
<h1>Radd PRO Uploader</h1>
|
| 347 |
<form id="uploadForm">
|
| 348 |
<div id="dropZone" class="drop-zone">
|
| 349 |
+
<input type="file" name="file" id="file" class="file-input" accept=".zip,.mp4,.txt,.mp3,image/*,.pdf" required>
|
| 350 |
<label for="file" class="btn">Choose File</label>
|
| 351 |
<p>or drag and drop file here/paste image</p>
|
| 352 |
</div>
|
|
|
|
| 363 |
|
| 364 |
<div id="embedModal" class="modal">
|
| 365 |
<div class="modal-content">
|
| 366 |
+
<span class="close">×</span>
|
| 367 |
<h2>Embed Video Link</h2>
|
| 368 |
<p>Copy the following link to embed the video:</p>
|
| 369 |
<div class="embed-container">
|
| 370 |
<input type="text" id="embedLink" readonly>
|
| 371 |
+
<button onclick="copyEmbedLink()" class="small-btn copy-embed-btn">Copy</button>
|
| 372 |
</div>
|
| 373 |
</div>
|
| 374 |
</div>
|
|
|
|
| 394 |
}
|
| 395 |
});
|
| 396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
dropZone.addEventListener('dragover', (e) => {
|
| 398 |
e.preventDefault();
|
| 399 |
dropZone.classList.add('drag-over');
|
|
|
|
| 512 |
|
| 513 |
const link = document.createElement('a');
|
| 514 |
link.href = url;
|
| 515 |
+
link.textContent = `View ${fileName}`;
|
| 516 |
link.className = 'result-link';
|
| 517 |
link.target = '_blank';
|
| 518 |
|
| 519 |
const copyBtn = document.createElement('button');
|
| 520 |
copyBtn.textContent = 'Copy Link';
|
| 521 |
+
copyBtn.className = 'small-btn copy-btn';
|
| 522 |
copyBtn.onclick = () => {
|
| 523 |
navigator.clipboard.writeText(window.location.origin + url).then(() => {
|
| 524 |
alert('Link copied to clipboard!');
|
|
|
|
| 531 |
if (fileName.toLowerCase().endsWith('.mp4')) {
|
| 532 |
const embedBtn = document.createElement('button');
|
| 533 |
embedBtn.textContent = 'Embed Video for Discord';
|
| 534 |
+
embedBtn.className = 'small-btn embed-btn';
|
| 535 |
embedBtn.onclick = () => {
|
| 536 |
showEmbedModal(url);
|
| 537 |
};
|
|
|
|
| 543 |
}
|
| 544 |
|
| 545 |
function showEmbedModal(url) {
|
| 546 |
+
const embedUrl = `${window.location.origin}/embed?url=${encodeURIComponent(window.location.origin + url)}&thumbnail=${encodeURIComponent('https://example.com/thumbnail.png')}`;
|
| 547 |
embedLinkInput.value = embedUrl;
|
| 548 |
modal.style.display = "block";
|
| 549 |
}
|
|
|
|
| 598 |
yield chunk
|
| 599 |
|
| 600 |
headers = dict(response.headers)
|
| 601 |
+
headers['Access-Control-Allow-Origin'] = '*'
|
| 602 |
headers['Content-Disposition'] = 'inline'
|
| 603 |
|
| 604 |
if response.status_code == 206:
|
|
|
|
| 662 |
try:
|
| 663 |
response = requests.post(url, cookies=cookies, headers={
|
| 664 |
'X-CSRFToken': cookies.get('csrftoken'),
|
| 665 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
|
| 666 |
'Referer': 'https://replicate.com/levelsio/neon-tokyo',
|
| 667 |
'Origin': 'https://replicate.com',
|
| 668 |
+
'Accept': '*/*',
|
| 669 |
'Accept-Language': 'en-US,en;q=0.5',
|
| 670 |
'Accept-Encoding': 'identity',
|
| 671 |
'Sec-Fetch-Dest': 'empty',
|