attendantelectro commited on
Commit
8e61864
·
verified ·
1 Parent(s): 6ed77c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -14
app.py CHANGED
@@ -1,12 +1,6 @@
1
- # app.py
2
 
3
- import os
4
- import io
5
- import zipfile
6
- import tempfile
7
- from werkzeug.utils import secure_filename
8
- import streamlit as st
9
- from api import ALLOWED_EXTENSIONS, allowed_file, convert_path
10
 
11
  Streamlit page configuration
12
 
@@ -16,8 +10,6 @@ Multilingual interface text
16
 
17
  TEXTS = { "English": { "title": "Universal File Converter", "desc": "Convert files or archives (ZIP, RAR, PDF, WAV, MP4, Images)", "upload": "Upload File", "convert_btn": "Convert", "processing": "Processing...", "error_type": "Unsupported file type!", "success": "Conversion successful!", "download": "Download" }, "فارسی": { "title": "مبدل جهانی فایل", "desc": "تبدیل فایل یا آرشیو (ZIP, RAR, PDF, WAV, MP4, تصاویر)", "upload": "آپلود فایل", "convert_btn": "تبدیل", "processing": "در حال پردازش...", "error_type": "نوع فایل پشتیبانی نمیشود!", "success": "تبدیل با موفقیت انجام شد!", "download": "دانلود" } }
18
 
19
- Language selection
20
-
21
  def main(): lang = st.sidebar.selectbox("", list(TEXTS.keys())) T = TEXTS[lang]
22
 
23
  st.title(T['title'])
@@ -38,8 +30,8 @@ if uploaded:
38
 
39
  if len(converted_files) == 1:
40
  out_path = converted_files[0]
41
- with open(out_path, 'rb') as f:
42
- data = f.read()
43
  st.success(T['success'])
44
  st.download_button(T['download'], data, os.path.basename(out_path))
45
  else:
@@ -50,5 +42,4 @@ if uploaded:
50
  st.success(T['success'])
51
  st.download_button(T['download'], zip_buffer.getvalue(), 'converted_files.zip')
52
 
53
- if name == 'main': main()
54
-
 
1
+ #app.py
2
 
3
+ import os import io import zipfile import tempfile from werkzeug.utils import secure_filename import streamlit as st from api import ALLOWED_EXTENSIONS, allowed_file, convert_path
 
 
 
 
 
 
4
 
5
  Streamlit page configuration
6
 
 
10
 
11
  TEXTS = { "English": { "title": "Universal File Converter", "desc": "Convert files or archives (ZIP, RAR, PDF, WAV, MP4, Images)", "upload": "Upload File", "convert_btn": "Convert", "processing": "Processing...", "error_type": "Unsupported file type!", "success": "Conversion successful!", "download": "Download" }, "فارسی": { "title": "مبدل جهانی فایل", "desc": "تبدیل فایل یا آرشیو (ZIP, RAR, PDF, WAV, MP4, تصاویر)", "upload": "آپلود فایل", "convert_btn": "تبدیل", "processing": "در حال پردازش...", "error_type": "نوع فایل پشتیبانی نمیشود!", "success": "تبدیل با موفقیت انجام شد!", "download": "دانلود" } }
12
 
 
 
13
  def main(): lang = st.sidebar.selectbox("", list(TEXTS.keys())) T = TEXTS[lang]
14
 
15
  st.title(T['title'])
 
30
 
31
  if len(converted_files) == 1:
32
  out_path = converted_files[0]
33
+ with open(out_path, 'rb') as f2:
34
+ data = f2.read()
35
  st.success(T['success'])
36
  st.download_button(T['download'], data, os.path.basename(out_path))
37
  else:
 
42
  st.success(T['success'])
43
  st.download_button(T['download'], zip_buffer.getvalue(), 'converted_files.zip')
44
 
45
+ if name == 'main': main()