SnowFlash383935 commited on
Commit
fcf7884
·
verified ·
1 Parent(s): cf987b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -3
app.py CHANGED
@@ -2,8 +2,8 @@ import gradio as gr
2
  import fanl_yp
3
  import zlib
4
 
5
- def greet(gameFilePath: str):
6
- gameFile = open(gameFilePath, "br")
7
  data = zlib.decompress(gameFile.read())
8
  gameFile.close()
9
  game = fanl_yp.decode.decode(data)
@@ -12,5 +12,28 @@ def greet(gameFilePath: str):
12
  output.flush()
13
  return gameFilePath + "_fixed"
14
 
15
- demo = gr.Interface(fn=greet, inputs=["file"], outputs=["file"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  demo.launch()
 
2
  import fanl_yp
3
  import zlib
4
 
5
+ def process_save_file(gameFilePath: str):
6
+ gameFile = open(gameFilePath, "rb")
7
  data = zlib.decompress(gameFile.read())
8
  gameFile.close()
9
  game = fanl_yp.decode.decode(data)
 
12
  output.flush()
13
  return gameFilePath + "_fixed"
14
 
15
+ with gr.Blocks() as demo:
16
+ file_input = gr.File(label="Загрузите файл сохранения")
17
+ info_text = gr.Textbox(label="Информация", interactive=False, value="")
18
+ run_button = gr.Button("Выполнить", interactive=False)
19
+ file_output = gr.File(label="Результат")
20
+
21
+ def on_file_upload(file_obj):
22
+ if file_obj is not None:
23
+ return "Hello world", gr.update(interactive=True)
24
+ else:
25
+ return "", gr.update(interactive=False)
26
+
27
+ file_input.change(
28
+ fn=on_file_upload,
29
+ inputs=file_input,
30
+ outputs=[info_text, run_button]
31
+ )
32
+
33
+ run_button.click(
34
+ fn=process_save_file,
35
+ inputs=file_input,
36
+ outputs=file_output
37
+ )
38
+
39
  demo.launch()