Added new chat page and fixed JSON error
This commit is contained in:
16
main.py
16
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)
|
||||
|
||||
Reference in New Issue
Block a user