Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,142 +1,3 @@
|
|
| 1 |
-
Yasmineben
|
| 2 |
-
yasmineben0327
|
| 3 |
-
En ligne
|
| 4 |
-
|
| 5 |
-
Yasmineben — 21/04/2025 21:37
|
| 6 |
-
CCCCCCCC
|
| 7 |
-
Rayhane — Hier à 21:13
|
| 8 |
-
HIII
|
| 9 |
-
from fastapi import FastAPI, File, UploadFile, HTTPException, Form
|
| 10 |
-
from fastapi.responses import HTMLResponse
|
| 11 |
-
from fastapi.staticfiles import StaticFiles
|
| 12 |
-
from transformers import pipeline
|
| 13 |
-
import textwrap
|
| 14 |
-
import fitz # PyMuPDF for PDF handling
|
| 15 |
-
Afficher plus
|
| 16 |
-
message.txt
|
| 17 |
-
6 Ko
|
| 18 |
-
Code python
|
| 19 |
-
Rayhane — Hier à 21:22
|
| 20 |
-
<!DOCTYPE html>
|
| 21 |
-
<html lang="fr">
|
| 22 |
-
<head>
|
| 23 |
-
<meta charset="UTF-8">
|
| 24 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 25 |
-
<title>AI Document Translator Pro</title>
|
| 26 |
-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 27 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 28 |
-
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
| 29 |
-
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
| 30 |
-
<style>
|
| 31 |
-
:root {
|
| 32 |
-
--primary-color: #4361ee;
|
| 33 |
-
--secondary-color: #3f37c9;
|
| 34 |
-
--accent-color: #4cc9f0;
|
| 35 |
-
--dark-color: #1a1a2e;
|
| 36 |
-
--light-color: #f8f9fa;
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
body {
|
| 40 |
-
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
| 41 |
-
color: var(--dark-color);
|
| 42 |
-
min-height: 100vh;
|
| 43 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
.main-container {
|
| 47 |
-
max-width: 800px;
|
| 48 |
-
background: white;
|
| 49 |
-
padding: 2rem;
|
| 50 |
-
border-radius: 15px;
|
| 51 |
-
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
| 52 |
-
margin: 2rem auto;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
.header {
|
| 56 |
-
text-align: center;
|
| 57 |
-
margin-bottom: 2rem;
|
| 58 |
-
position: relative;
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
.logo {
|
| 62 |
-
font-size: 2.5rem;
|
| 63 |
-
color: var(--primary-color);
|
| 64 |
-
margin-bottom: 0.5rem;
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
.title {
|
| 68 |
-
font-weight: 700;
|
| 69 |
-
color: var(--dark-color);
|
| 70 |
-
margin-bottom: 0.5rem;
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
.subtitle {
|
| 74 |
-
color: #6c757d;
|
| 75 |
-
font-size: 1rem;
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
.upload-section {
|
| 79 |
-
background: rgba(67, 97, 238, 0.05);
|
| 80 |
-
border: 2px dashed rgba(67, 97, 238, 0.3);
|
| 81 |
-
border-radius: 10px;
|
| 82 |
-
padding: 2rem;
|
| 83 |
-
margin-bottom: 2rem;
|
| 84 |
-
transition: all 0.3s ease;
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
.upload-section:hover {
|
| 88 |
-
border-color: var(--primary-color);
|
| 89 |
-
background: rgba(67, 97, 238, 0.1);
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
.file-info {
|
| 93 |
-
background: var(--light-color);
|
| 94 |
-
padding: 0.5rem;
|
| 95 |
-
border-radius: 5px;
|
| 96 |
-
font-size: 0.9rem;
|
| 97 |
-
margin-top: 1rem;
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
.form-control, .form-select {
|
| 101 |
-
border-radius: 8px;
|
| 102 |
-
padding: 0.75rem 1rem;
|
| 103 |
-
border: 1px solid #ced4da;
|
| 104 |
-
transition: all 0.3s ease;
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
.form-control:focus, .form-select:focus {
|
| 108 |
-
border-color: var(--primary-color);
|
| 109 |
-
box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.25);
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
.btn-primary {
|
| 113 |
-
background-color: var(--primary-color);
|
| 114 |
-
border-color: var(--primary-color);
|
| 115 |
-
border-radius: 8px;
|
| 116 |
-
padding: 0.75rem 1.5rem;
|
| 117 |
-
font-weight: 600;
|
| 118 |
-
transition: all 0.3s ease;
|
| 119 |
-
}
|
| 120 |
-
... (252lignes restantes)
|
| 121 |
-
Réduire
|
| 122 |
-
message.txt
|
| 123 |
-
14 Ko
|
| 124 |
-
hadi html
|
| 125 |
-
fastapi
|
| 126 |
-
uvicorn
|
| 127 |
-
transformers
|
| 128 |
-
torch
|
| 129 |
-
PyMuPDF
|
| 130 |
-
python-docx
|
| 131 |
-
openpyxl
|
| 132 |
-
python-pptx
|
| 133 |
-
textwrap3
|
| 134 |
-
python-multipart
|
| 135 |
-
sentencepiece
|
| 136 |
-
hadi requirments.txt
|
| 137 |
-
|
| 138 |
-
Rayhane
|
| 139 |
-
rayhane0778_65551
|
| 140 |
from fastapi import FastAPI, File, UploadFile, HTTPException, Form
|
| 141 |
from fastapi.responses import HTMLResponse
|
| 142 |
from fastapi.staticfiles import StaticFiles
|
|
@@ -293,5 +154,4 @@ async def upload_file(
|
|
| 293 |
return {"translated_text": translated_text}
|
| 294 |
|
| 295 |
except Exception as e:
|
| 296 |
-
raise HTTPException(status_code=500, detail=f"Internal error: {str(e)}")
|
| 297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile, HTTPException, Form
|
| 2 |
from fastapi.responses import HTMLResponse
|
| 3 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
| 154 |
return {"translated_text": translated_text}
|
| 155 |
|
| 156 |
except Exception as e:
|
| 157 |
+
raise HTTPException(status_code=500, detail=f"Internal error: {str(e)}")
|
|
|