tori29umai commited on
Commit
d2d29d4
·
verified ·
1 Parent(s): 71192b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -227,7 +227,12 @@ def upload_ini(file):
227
  if file is None:
228
  return "ファイルがアップロードされていません。"
229
 
230
- content = file.decode('utf-8')
 
 
 
 
 
231
  config = configparser.ConfigParser()
232
  config.read_string(content)
233
 
@@ -320,7 +325,7 @@ with gr.Blocks(css=custom_css) as iface:
320
  save_ini_output = gr.File(label="保存されたINIファイル")
321
 
322
  # INIファイルをアップロードして読み込むボタン
323
- upload_ini_button = gr.File(label="INIファイルをアップロード")
324
  upload_ini_output = gr.Textbox(label="アップロード状態")
325
 
326
  # INIファイルをローカルに保存する関数
 
227
  if file is None:
228
  return "ファイルがアップロードされていません。"
229
 
230
+ try:
231
+ content = file.decode('utf-8')
232
+ except AttributeError:
233
+ # ファイルが既にテキスト形式の場合
234
+ content = file
235
+
236
  config = configparser.ConfigParser()
237
  config.read_string(content)
238
 
 
325
  save_ini_output = gr.File(label="保存されたINIファイル")
326
 
327
  # INIファイルをアップロードして読み込むボタン
328
+ upload_ini_button = gr.File(label="INIファイルをアップロード", type="text")
329
  upload_ini_output = gr.Textbox(label="アップロード状態")
330
 
331
  # INIファイルをローカルに保存する関数