mosibi/man
0
1import os
2import sys
3import gradio as gr
4from assets.i18n.i18n import I18nAuto
5import requests
6
7now_dir = os.getcwd()
8sys.path.append(now_dir)
9
10from assets.flask.server import start_flask, load_config_flask, save_config
11
12i18n = I18nAuto()
13
14
15def flask_server_tab():
16 with gr.Row():
17 with gr.Column():
18 flask_checkbox = gr.Checkbox(
19 label=i18n(
20 "Enable Applio integration with applio.org/models using flask"
21 ),
22 info=i18n(
23 "It will activate the possibility of downloading models with a click from the website."
24 ),
25 interactive=True,
26 value=load_config_flask(),
27 )
28 flask_checkbox.change(
29 fn=toggle,
30 inputs=[flask_checkbox],
31 outputs=[],
32 )
33
34
35def toggle(checkbox):
36 save_config(bool(checkbox))
37 if load_config_flask() == True:
38 start_flask()
39 else:
40 try:
41 requests.post("http://localhost:8000/shutdown")
42 except requests.exceptions.ConnectionError:
43 pass
44 