Spaces:
Runtime error
Runtime error
Miguel Diaz commited on
Commit ·
d540822
1
Parent(s): 110259e
fix: statics
Browse files- main.py +1 -1
- static/js/windowHandler.js +10 -0
- static/main.html +12 -23
main.py
CHANGED
|
@@ -65,7 +65,7 @@ async def root(request: Request, credentials: HTTPBasicCredentials = Depends(sec
|
|
| 65 |
if authenticate_user(credentials):
|
| 66 |
token = create_jwt_token({"user":credentials.username})
|
| 67 |
with open(os.path.join("static", "main.html")) as f:
|
| 68 |
-
return HTMLResponse(f.read().replace("{% token %}", token).replace("{% version %}", "
|
| 69 |
|
| 70 |
|
| 71 |
@app.post("/chat_stream")
|
|
|
|
| 65 |
if authenticate_user(credentials):
|
| 66 |
token = create_jwt_token({"user":credentials.username})
|
| 67 |
with open(os.path.join("static", "main.html")) as f:
|
| 68 |
+
return HTMLResponse(f.read().replace("{% token %}", token).replace("{% version %}", "7"))
|
| 69 |
|
| 70 |
|
| 71 |
@app.post("/chat_stream")
|
static/js/windowHandler.js
CHANGED
|
@@ -19,6 +19,16 @@ class WindowHandler{
|
|
| 19 |
this.precargaMensaje(params.mensaje, "fallido")
|
| 20 |
}
|
| 21 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
limpiarChat(){
|
|
|
|
| 19 |
this.precargaMensaje(params.mensaje, "fallido")
|
| 20 |
}
|
| 21 |
});
|
| 22 |
+
|
| 23 |
+
$("#input-text").keypress(function(event){
|
| 24 |
+
if (!event.shiftKey && event.keyCode === 13) {
|
| 25 |
+
this.manejadorEnviar();
|
| 26 |
+
}});
|
| 27 |
+
$("#input-send").click(this.manejadorEnviar);
|
| 28 |
+
$("#input-text").keypress(this.recaularTextarea);
|
| 29 |
+
$("#input-text").keyup(this.recaularTextarea);
|
| 30 |
+
$("#input-text").keydown(this.recaularTextarea);
|
| 31 |
+
this.cargarChat(chatH.convesacion);
|
| 32 |
}
|
| 33 |
|
| 34 |
limpiarChat(){
|
static/main.html
CHANGED
|
@@ -10,29 +10,7 @@
|
|
| 10 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha512-SkmBfuA2hqjzEVpmnMt/LINrjop3GKWqsuLSSB3e7iBmYK7JuWw4ldmmxwD9mdm2IRTTi0OxSAfEGvgEi0i2Kw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
| 11 |
<script src="static/js/chatHandler.js?v={% version %}"></script>
|
| 12 |
<script src="static/js/windowHandler.js?v={% version %}"></script>
|
| 13 |
-
|
| 14 |
-
let windH = null;
|
| 15 |
-
let chatH = null;
|
| 16 |
-
try {
|
| 17 |
-
$(document).ready(function() {
|
| 18 |
-
windH = new WindowHandler();
|
| 19 |
-
chatH = new ChatGPT("{% token %}");
|
| 20 |
-
$("#input-text").keypress(function(event){
|
| 21 |
-
if (!event.shiftKey && event.keyCode === 13) {
|
| 22 |
-
windH.manejadorEnviar();
|
| 23 |
-
}});
|
| 24 |
-
$("#input-send").click(windH.manejadorEnviar);
|
| 25 |
-
|
| 26 |
-
$("#input-text").keypress(windH.recaularTextarea);
|
| 27 |
-
$("#input-text").keyup(windH.recaularTextarea);
|
| 28 |
-
$("#input-text").keydown(windH.recaularTextarea);
|
| 29 |
-
windH.cargarChat(chatH.convesacion);
|
| 30 |
-
});
|
| 31 |
-
}
|
| 32 |
-
catch(err) {
|
| 33 |
-
document.write(err)
|
| 34 |
-
}
|
| 35 |
-
</script>
|
| 36 |
</head>
|
| 37 |
<body>
|
| 38 |
<div class="wrapper">
|
|
@@ -51,5 +29,16 @@
|
|
| 51 |
</div>
|
| 52 |
|
| 53 |
<div id="message-template" class="message"><div><p></p></div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
</body>
|
| 55 |
</html>
|
|
|
|
| 10 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha512-SkmBfuA2hqjzEVpmnMt/LINrjop3GKWqsuLSSB3e7iBmYK7JuWw4ldmmxwD9mdm2IRTTi0OxSAfEGvgEi0i2Kw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
| 11 |
<script src="static/js/chatHandler.js?v={% version %}"></script>
|
| 12 |
<script src="static/js/windowHandler.js?v={% version %}"></script>
|
| 13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
</head>
|
| 15 |
<body>
|
| 16 |
<div class="wrapper">
|
|
|
|
| 29 |
</div>
|
| 30 |
|
| 31 |
<div id="message-template" class="message"><div><p></p></div></div>
|
| 32 |
+
|
| 33 |
+
<script>
|
| 34 |
+
let windH = null;
|
| 35 |
+
let chatH = null;
|
| 36 |
+
|
| 37 |
+
$(document).ready(function() {
|
| 38 |
+
chatH = new ChatGPT("{% token %}");
|
| 39 |
+
windH = new WindowHandler();
|
| 40 |
+
});
|
| 41 |
+
|
| 42 |
+
</script>
|
| 43 |
</body>
|
| 44 |
</html>
|