mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-03-11 15:03:55 +00:00
Merge pull request #136 from chongy076/chong-app_patch1
Chong app patch1 - Improve socket serving and prevent session timeout
This commit is contained in:
commit
49bc2ef95b
17
app.py
17
app.py
@ -40,7 +40,7 @@ from geventwebsocket.handler import WebSocketHandler
|
|||||||
from gevent.pywsgi import WSGIServer
|
from gevent.pywsgi import WSGIServer
|
||||||
|
|
||||||
app = Flask("GPT4All-WebUI", static_url_path="/static", static_folder="static")
|
app = Flask("GPT4All-WebUI", static_url_path="/static", static_folder="static")
|
||||||
socketio = SocketIO(app, async_mode='gevent')
|
socketio = SocketIO(app, async_mode='gevent', ping_timeout=30, ping_interval=15)
|
||||||
app.config['SECRET_KEY'] = 'secret!'
|
app.config['SECRET_KEY'] = 'secret!'
|
||||||
# Set the logging level to WARNING or higher
|
# Set the logging level to WARNING or higher
|
||||||
logging.getLogger('socketio').setLevel(logging.WARNING)
|
logging.getLogger('socketio').setLevel(logging.WARNING)
|
||||||
@ -610,7 +610,6 @@ if __name__ == "__main__":
|
|||||||
# app.config['executor'] = executor
|
# app.config['executor'] = executor
|
||||||
bot = Gpt4AllWebUI(app, socketio, config, personality, config_file_path)
|
bot = Gpt4AllWebUI(app, socketio, config, personality, config_file_path)
|
||||||
|
|
||||||
|
|
||||||
# chong Define custom WebSocketHandler with error handling
|
# chong Define custom WebSocketHandler with error handling
|
||||||
class CustomWebSocketHandler(WebSocketHandler):
|
class CustomWebSocketHandler(WebSocketHandler):
|
||||||
def handle_error(self, environ, start_response, e):
|
def handle_error(self, environ, start_response, e):
|
||||||
@ -618,19 +617,19 @@ if __name__ == "__main__":
|
|||||||
print("WebSocket error:", e)
|
print("WebSocket error:", e)
|
||||||
super().handle_error(environ, start_response, e)
|
super().handle_error(environ, start_response, e)
|
||||||
|
|
||||||
# chong -add socket server
|
|
||||||
http_server = WSGIServer((config["host"], config["port"]), app, handler_class=CustomWebSocketHandler)
|
|
||||||
http_server = WSGIServer((config["host"], config["port"]), app, handler_class=WebSocketHandler)
|
|
||||||
|
|
||||||
url = f'http://{config["host"]}:{config["port"]}'
|
url = f'http://{config["host"]}:{config["port"]}'
|
||||||
|
|
||||||
print(f"Please open your browser and go to {url} to view the ui")
|
print(f"Please open your browser and go to {url} to view the ui")
|
||||||
|
|
||||||
|
# chong -add socket server
|
||||||
|
app.config['debug'] = config["debug"]
|
||||||
|
|
||||||
if config["debug"]:
|
if config["debug"]:
|
||||||
socketio.run(app,debug=True, host=config["host"], port=config["port"])
|
print("debug mode:true")
|
||||||
else:
|
else:
|
||||||
socketio.run(app, host=config["host"], port=config["port"])
|
print("debug mode:false")
|
||||||
|
|
||||||
|
|
||||||
|
http_server = WSGIServer((config["host"], config["port"]), app, handler_class=WebSocketHandler)
|
||||||
|
|
||||||
# if config["debug"]:
|
# if config["debug"]:
|
||||||
# app.run(debug=True, host=config["host"], port=config["port"])
|
# app.run(debug=True, host=config["host"], port=config["port"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user