Spaces:
Runtime error
Runtime error
Commit
·
c0f3434
1
Parent(s):
4a794f1
English-Malayalam Translate v28
Browse files- main.py +6 -5
- static/index.html +1 -1
- static/script.js +1 -1
main.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import os
|
2 |
from fastapi import FastAPI, Request
|
3 |
from fastapi.staticfiles import StaticFiles
|
4 |
-
from fastapi.responses import
|
5 |
from fastapi.templating import Jinja2Templates
|
6 |
from transformers import pipeline
|
7 |
|
@@ -18,12 +18,13 @@ def t5(input):
|
|
18 |
|
19 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
templates = Jinja2Templates(directory="templates")
|
25 |
|
26 |
-
@app.get("/")
|
27 |
async def index():
|
28 |
apikey = {"APIKEY": os.environ.get("API_KEY")}
|
29 |
return templates.TemplateResponse("chat.html", {"apikey": apikey})
|
|
|
1 |
import os
|
2 |
from fastapi import FastAPI, Request
|
3 |
from fastapi.staticfiles import StaticFiles
|
4 |
+
from fastapi.responses import FileResponse
|
5 |
from fastapi.templating import Jinja2Templates
|
6 |
from transformers import pipeline
|
7 |
|
|
|
18 |
|
19 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
20 |
|
21 |
+
@app.get("/")
|
22 |
+
def index() -> FileResponse:
|
23 |
+
return FileResponse(path="/app/static/index.html", media_type="text/html")
|
24 |
+
|
25 |
templates = Jinja2Templates(directory="templates")
|
26 |
|
27 |
+
@app.get("/chat")
|
28 |
async def index():
|
29 |
apikey = {"APIKEY": os.environ.get("API_KEY")}
|
30 |
return templates.TemplateResponse("chat.html", {"apikey": apikey})
|
static/index.html
CHANGED
@@ -4,6 +4,6 @@
|
|
4 |
</head>
|
5 |
<body>
|
6 |
<!-- Include your script file -->
|
7 |
-
<script src="
|
8 |
</body>
|
9 |
</html>
|
|
|
4 |
</head>
|
5 |
<body>
|
6 |
<!-- Include your script file -->
|
7 |
+
<script src="script.js"></script>
|
8 |
</body>
|
9 |
</html>
|
static/script.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
const xhr = new XMLHttpRequest();
|
2 |
-
xhr.open('GET', '/');
|
3 |
xhr.onload = function() {
|
4 |
if (xhr.status === 200) {
|
5 |
// Update the DOM with the rendered HTML
|
|
|
1 |
const xhr = new XMLHttpRequest();
|
2 |
+
xhr.open('GET', '/chat');
|
3 |
xhr.onload = function() {
|
4 |
if (xhr.status === 200) {
|
5 |
// Update the DOM with the rendered HTML
|