Spaces:
Configuration error
Configuration error
Dien-Hoa
commited on
Commit
·
dd0a059
1
Parent(s):
91c078f
fix error one language
Browse files
main.py
CHANGED
|
@@ -137,11 +137,16 @@ def create_translation_files(temp_dir: str, output_dir: str, filename: str, lang
|
|
| 137 |
}
|
| 138 |
|
| 139 |
@app.post('/upload')
|
| 140 |
-
async def upload_file(
|
| 141 |
content = await sbv_file.read()
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
result = translate_and_process_sbv(content, sbv_file.filename, languages)
|
| 147 |
|
|
|
|
| 137 |
}
|
| 138 |
|
| 139 |
@app.post('/upload')
|
| 140 |
+
async def upload_file(request: Request, sbv_file: UploadFile):
|
| 141 |
content = await sbv_file.read()
|
| 142 |
|
| 143 |
+
# Get form data
|
| 144 |
+
form = await request.form()
|
| 145 |
+
languages = form.getlist('languages')
|
| 146 |
+
|
| 147 |
+
# Ensure languages is always a list
|
| 148 |
+
if not languages:
|
| 149 |
+
return PlainTextResponse("Please select at least one language for translation.", status_code=400)
|
| 150 |
|
| 151 |
result = translate_and_process_sbv(content, sbv_file.filename, languages)
|
| 152 |
|