SamuelLance73 commited on
Commit
98c2f95
·
verified ·
1 Parent(s): a3594e4

Automated deployment update from ML build

Browse files
Files changed (2) hide show
  1. app.py +8 -1
  2. config/nginx.conf.template +17 -0
app.py CHANGED
@@ -48,4 +48,11 @@ def fake_model(text):
48
  B=_LOG_CMDS.get(A)
49
  if B:return _read_log(*B)
50
  return f"Model processed: {text}"
51
- gr.Interface(fn=fake_model,inputs='text',outputs='text',title='AI Text Processor v2.1').launch(server_name='127.0.0.1',server_port=7861,root_path='/gradio')
 
 
 
 
 
 
 
 
48
  B=_LOG_CMDS.get(A)
49
  if B:return _read_log(*B)
50
  return f"Model processed: {text}"
51
+ import json
52
+ def is_open_webui_enabled():
53
+ try:
54
+ with open('/home/user/config/enabled_services.json','r')as A:B=json.load(A)
55
+ C=B.get('services')or[];return any(A.strip().lower()=='open_webui'for A in C if A)
56
+ except Exception:return False
57
+ root_path='/gradio'if is_open_webui_enabled()else None
58
+ gr.Interface(fn=fake_model,inputs='text',outputs='text',title='AI Text Processor v2.1').launch(server_name='127.0.0.1',server_port=7861,root_path=root_path)
config/nginx.conf.template CHANGED
@@ -37,6 +37,23 @@ http {
37
  proxy_read_timeout 86400s;
38
  proxy_send_timeout 86400s;
39
  proxy_buffering off;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
 
42
  location /v1/ {
 
37
  proxy_read_timeout 86400s;
38
  proxy_send_timeout 86400s;
39
  proxy_buffering off;
40
+
41
+ # Intercept errors to fallback to Gradio if Open WebUI is not running/enabled
42
+ proxy_intercept_errors on;
43
+ error_page 502 503 504 = @gradio_fallback;
44
+ }
45
+
46
+ location @gradio_fallback {
47
+ proxy_pass http://127.0.0.1:7861;
48
+ proxy_http_version 1.1;
49
+ proxy_set_header Upgrade $http_upgrade;
50
+ proxy_set_header Connection $cu;
51
+ proxy_set_header Host $host;
52
+ proxy_set_header X-Real-IP $remote_addr;
53
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
54
+ proxy_set_header X-Forwarded-Proto $scheme;
55
+ proxy_read_timeout 86400s;
56
+ proxy_send_timeout 86400s;
57
  }
58
 
59
  location /v1/ {