gpt4free/g4f/gui/server/website.py

38 lines
1.1 KiB
Python
Raw Normal View History

2024-03-16 12:48:37 +03:00
import uuid
from flask import render_template, redirect
2023-10-06 21:52:17 +03:00
class Website:
def __init__(self, app) -> None:
self.app = app
def redirect_home():
return redirect('/chat')
2023-10-06 21:52:17 +03:00
self.routes = {
'/': {
'function': redirect_home,
2023-10-06 21:52:17 +03:00
'methods': ['GET', 'POST']
},
'/chat/': {
'function': self._index,
'methods': ['GET', 'POST']
},
'/chat/<conversation_id>': {
'function': self._chat,
'methods': ['GET', 'POST']
},
'/menu/': {
'function': redirect_home,
'methods': ['GET', 'POST']
},
'/settings/': {
'function': redirect_home,
'methods': ['GET', 'POST']
},
2023-10-06 21:52:17 +03:00
}
def _chat(self, conversation_id):
if '-' not in conversation_id:
return redirect('/chat')
2024-03-16 12:48:37 +03:00
return render_template('index.html', chat_id=conversation_id)
2023-10-06 21:52:17 +03:00
def _index(self):
2024-03-16 12:48:37 +03:00
return render_template('index.html', chat_id=str(uuid.uuid4()))