P01yH3dr0n commited on
Commit
31ebff9
β€’
1 Parent(s): bc7cbda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -151,14 +151,26 @@ def util_ui():
151
  items = gr.JSON(value=None, visible=False)
152
  png2main = gr.Button('ε‚ζ•°ε‘ι€εˆ°ζ–‡η”Ÿε›Ύ')
153
  return page, png2main, items, info, image
154
-
155
- def ui():
156
  head = ''
157
  with open('jsReloader.js', 'r', encoding='utf8') as j:
158
  head += f'<script>{j.read()}</script>\n'
159
  for f in sorted(os.listdir('./tagcomplete/javascript')):
160
  head += f'<script type="text/javascript" src="file=tagcomplete/javascript/{f}"></script>\n'
161
- with gr.Blocks(title="NAI Client", head=head, theme=gr.themes.Base()) as website:
 
 
 
 
 
 
 
 
 
 
 
 
162
  with gr.Tabs():
163
  with gr.TabItem("ζ–‡η”Ÿε›Ύ", elem_id="client_ui_main"):
164
  _, paras = main_ui()
 
151
  items = gr.JSON(value=None, visible=False)
152
  png2main = gr.Button('ε‚ζ•°ε‘ι€εˆ°ζ–‡η”Ÿε›Ύ')
153
  return page, png2main, items, info, image
154
+
155
+ def load_javascript():
156
  head = ''
157
  with open('jsReloader.js', 'r', encoding='utf8') as j:
158
  head += f'<script>{j.read()}</script>\n'
159
  for f in sorted(os.listdir('./tagcomplete/javascript')):
160
  head += f'<script type="text/javascript" src="file=tagcomplete/javascript/{f}"></script>\n'
161
+
162
+ share = gr.routes.templates.TemplateResponse
163
+ def template_response(*args, **kwargs):
164
+ res = share(*args, **kwargs)
165
+ res.body = res.body.replace(b'</body>', f'{head}</body>'.encode("utf8"))
166
+ res.init_headers()
167
+ return res
168
+
169
+ gr.routes.templates.TemplateResponse = template_response
170
+
171
+ def ui():
172
+ load_javascript()
173
+ with gr.Blocks(title="NAI Client", theme=gr.themes.Base()) as website:
174
  with gr.Tabs():
175
  with gr.TabItem("ζ–‡η”Ÿε›Ύ", elem_id="client_ui_main"):
176
  _, paras = main_ui()