diff --git a/main.py b/main.py index e624294..d5ac69d 100644 --- a/main.py +++ b/main.py @@ -111,8 +111,7 @@ def generateMessage(_id): print(chunk['message']['content'], end='', flush=True) content = chunk['message']['content'] response += content - json_data = {"response": response} - yield f"data: {json.dumps(json_data)}\n\n" + yield f"data: {response}\n\n" return Response(generateStream(), mimetype='text/event-stream') else: @@ -238,6 +237,19 @@ def index(): else: render_template('logout.html', appName=appName) +@app.route('/chat/<_id>', methods = ['GET']) +def chatPage(_id): + token = request.cookies.get('auth_token', 'none') + if (token == 'none'): + return render_template('login.html', appName=appName, githubUrl=github_auth_endpoint, githublogin=settings["github_oauth"]["enabled"], oauthlogin=settings["oauth_login"]) + else: + a, userId = checkUserPermission(token, True) + if (a == True): + return render_template('chat.html', appName=appName, chatId=_id) + else: + render_template('logout.html', appName=appName) + + # Login endpoint # Api backend for login screen, check for user and returns token # Arguments: username (required), password (required) diff --git a/templates/chat.html b/templates/chat.html index e32fe02..729f67c 100644 --- a/templates/chat.html +++ b/templates/chat.html @@ -4,8 +4,493 @@ Chat | {{ appName }} + - - + + + + +
+
+ +
+ +
+ + +
+
+ + + - \ No newline at end of file + diff --git a/templates/chat.html.bak b/templates/chat.html.bak new file mode 100644 index 0000000..81786c5 --- /dev/null +++ b/templates/chat.html.bak @@ -0,0 +1,434 @@ + + + + + + Chat | {{ appName }} + + + + + + +
+
+ +
+ +
+ + +
+
+ + + + + diff --git a/templates/chattest.html b/templates/chattest.html index e1cdbbf..8472b3b 100644 --- a/templates/chattest.html +++ b/templates/chattest.html @@ -57,9 +57,8 @@ } const chunk = decoder.decode(value, { stream: true }); - const jsonString = chunk.substring(6); - const data = JSON.parse(jsonString); - outputArea.value = data["response"]; + const responseString = chunk.substring(6); + outputArea.value = responseString; } } catch (error) { console.error('An error has occurred:', error);