freemt commited on
Commit
39d4f47
·
1 Parent(s): ddce8cc

Update freeze_support() in app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -1,11 +1,9 @@
1
- import multiprocessing
2
  import gradio as gr
3
  import httpx
4
  from logzero import logger
5
  from deepl_fastapi.run_uvicorn import main
6
 
7
- multiprocessing.Process(target=main).start()
8
-
9
 
10
  def deepl(text, from_lang, to_lang):
11
  # "http://127.0.0.1:8000/text/?q=test%20me&to_lang=zh"
@@ -25,13 +23,17 @@ def deepl(text, from_lang, to_lang):
25
  return jdata.get("trtext")
26
 
27
 
28
- iface = gr.Interface(
29
- fn=deepl,
30
- inputs=[
31
- gr.Textbox(placeholder="Paste text here (max. 5000 chars)", lines=7,),
32
- gr.Textbox(label="from_lang", value="en", lines=1),
33
- gr.Textbox(label="to_lang", value="zh", lines=1),
34
- ],
35
- outputs="textarea"
36
- )
37
- iface.launch()
 
 
 
 
 
1
+ from multiprocessing import Process, freeze_support
2
  import gradio as gr
3
  import httpx
4
  from logzero import logger
5
  from deepl_fastapi.run_uvicorn import main
6
 
 
 
7
 
8
  def deepl(text, from_lang, to_lang):
9
  # "http://127.0.0.1:8000/text/?q=test%20me&to_lang=zh"
 
23
  return jdata.get("trtext")
24
 
25
 
26
+ if __name__ == "__main__":
27
+ freeze_support()
28
+ Process(target=main).start()
29
+
30
+ iface = gr.Interface(
31
+ fn=deepl,
32
+ inputs=[
33
+ gr.Textbox(placeholder="Paste text here (max. 5000 chars)", lines=7,),
34
+ gr.Textbox(label="from_lang", value="en", lines=1),
35
+ gr.Textbox(label="to_lang", value="zh", lines=1),
36
+ ],
37
+ outputs="textarea"
38
+ )
39
+ iface.launch()