Spaces:
Runtime error
Runtime error
Topallaj Denis
commited on
Commit
·
0beca83
1
Parent(s):
8d6ce18
fix endpoint query to form
Browse files- main.py +3 -6
- static/script.js +6 -6
- static/styles.css +45 -41
main.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from fastapi.staticfiles import StaticFiles
|
| 4 |
from fastapi.responses import FileResponse
|
|
@@ -39,11 +39,8 @@ def home() -> FileResponse:
|
|
| 39 |
return FileResponse(path="/app/static/index.html", media_type="text/html")
|
| 40 |
|
| 41 |
@app.get("/predict")
|
| 42 |
-
def predict_UniKP_values(
|
| 43 |
-
|
| 44 |
-
smiles: str
|
| 45 |
-
):
|
| 46 |
-
print(smiles)
|
| 47 |
endpointHandler = EndpointHandler()
|
| 48 |
result = endpointHandler.predict({
|
| 49 |
"inputs": {
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Form
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from fastapi.staticfiles import StaticFiles
|
| 4 |
from fastapi.responses import FileResponse
|
|
|
|
| 39 |
return FileResponse(path="/app/static/index.html", media_type="text/html")
|
| 40 |
|
| 41 |
@app.get("/predict")
|
| 42 |
+
def predict_UniKP_values(sequence: str = Form(...), smiles: str = Form(...)) -> Dict[str, float]:
|
| 43 |
+
|
|
|
|
|
|
|
|
|
|
| 44 |
endpointHandler = EndpointHandler()
|
| 45 |
result = endpointHandler.predict({
|
| 46 |
"inputs": {
|
static/script.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
| 1 |
"use strict";
|
| 2 |
|
| 3 |
-
document.
|
| 4 |
e.preventDefault();
|
| 5 |
-
const sequence = document.
|
| 6 |
-
const smiles = document.
|
| 7 |
|
| 8 |
console.log(sequence);
|
| 9 |
|
| 10 |
const data = await prediction(sequence, smiles);
|
| 11 |
|
| 12 |
-
document.
|
| 13 |
-
document.
|
| 14 |
-
document.
|
| 15 |
});
|
| 16 |
|
| 17 |
const prediction = async (sequence, smiles) => {
|
|
|
|
| 1 |
"use strict";
|
| 2 |
|
| 3 |
+
document.querySelector("#predict-form").addEventListener("submit", async (e) => {
|
| 4 |
e.preventDefault();
|
| 5 |
+
const sequence = document.querySelector("#sequence").value;
|
| 6 |
+
const smiles = document.querySelector("#substrate").value;
|
| 7 |
|
| 8 |
console.log(sequence);
|
| 9 |
|
| 10 |
const data = await prediction(sequence, smiles);
|
| 11 |
|
| 12 |
+
document.querySelector("#km-result").innerText = data.km;
|
| 13 |
+
document.querySelector("#kcat-result").innerText = data.kcat;
|
| 14 |
+
document.querySelector("#vmax-result").innerText = data.vmax;
|
| 15 |
});
|
| 16 |
|
| 17 |
const prediction = async (sequence, smiles) => {
|
static/styles.css
CHANGED
|
@@ -1,76 +1,80 @@
|
|
| 1 |
-
/*
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
body {
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
background-color: #f4f4f4;
|
| 8 |
}
|
| 9 |
|
| 10 |
.container {
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
}
|
| 18 |
|
| 19 |
h1 {
|
| 20 |
-
|
| 21 |
-
|
| 22 |
}
|
| 23 |
|
| 24 |
p {
|
| 25 |
-
|
| 26 |
}
|
| 27 |
|
| 28 |
form {
|
| 29 |
-
|
| 30 |
}
|
| 31 |
|
| 32 |
label {
|
| 33 |
-
|
| 34 |
-
|
| 35 |
}
|
| 36 |
|
| 37 |
input[type="text"] {
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
}
|
| 44 |
|
| 45 |
input[type="submit"] {
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
cursor: pointer;
|
| 53 |
-
transition: background-color 0.3s ease;
|
| 54 |
}
|
| 55 |
|
| 56 |
input[type="submit"]:hover {
|
| 57 |
-
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
#result-container {
|
| 61 |
-
display: none; /* Hide result container initially */
|
| 62 |
}
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
}
|
| 69 |
|
| 70 |
#result h3 {
|
| 71 |
-
|
|
|
|
| 72 |
}
|
| 73 |
|
| 74 |
#result p {
|
| 75 |
-
|
| 76 |
}
|
|
|
|
| 1 |
+
/* styles.css */
|
| 2 |
|
| 3 |
+
/* Resetting default margin and padding */
|
| 4 |
+
* {
|
| 5 |
+
margin: 0;
|
| 6 |
+
padding: 0;
|
| 7 |
+
box-sizing: border-box;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
/* Global styles */
|
| 11 |
body {
|
| 12 |
+
font-family: Arial, sans-serif;
|
| 13 |
+
background-color: #f0f0f0;
|
| 14 |
+
color: #333;
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
.container {
|
| 18 |
+
max-width: 600px;
|
| 19 |
+
margin: 20px auto;
|
| 20 |
+
padding: 20px;
|
| 21 |
+
background-color: #fff;
|
| 22 |
+
border-radius: 8px;
|
| 23 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
| 24 |
}
|
| 25 |
|
| 26 |
h1 {
|
| 27 |
+
font-size: 24px;
|
| 28 |
+
margin-bottom: 20px;
|
| 29 |
}
|
| 30 |
|
| 31 |
p {
|
| 32 |
+
margin-bottom: 20px;
|
| 33 |
}
|
| 34 |
|
| 35 |
form {
|
| 36 |
+
margin-bottom: 20px;
|
| 37 |
}
|
| 38 |
|
| 39 |
label {
|
| 40 |
+
display: block;
|
| 41 |
+
margin-bottom: 5px;
|
| 42 |
}
|
| 43 |
|
| 44 |
input[type="text"] {
|
| 45 |
+
width: 100%;
|
| 46 |
+
padding: 10px;
|
| 47 |
+
margin-bottom: 10px;
|
| 48 |
+
border: 1px solid #ccc;
|
| 49 |
+
border-radius: 4px;
|
| 50 |
}
|
| 51 |
|
| 52 |
input[type="submit"] {
|
| 53 |
+
background-color: #007bff;
|
| 54 |
+
color: #fff;
|
| 55 |
+
border: none;
|
| 56 |
+
padding: 10px 20px;
|
| 57 |
+
border-radius: 4px;
|
| 58 |
+
cursor: pointer;
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
input[type="submit"]:hover {
|
| 62 |
+
background-color: #0056b3;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
}
|
| 64 |
|
| 65 |
+
/* Result container styles */
|
| 66 |
+
#result-container #result {
|
| 67 |
+
background-color: #f9f9f9;
|
| 68 |
+
padding: 20px;
|
| 69 |
+
border-radius: 8px;
|
| 70 |
+
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
| 71 |
}
|
| 72 |
|
| 73 |
#result h3 {
|
| 74 |
+
font-size: 18px;
|
| 75 |
+
margin-bottom: 10px;
|
| 76 |
}
|
| 77 |
|
| 78 |
#result p {
|
| 79 |
+
margin-bottom: 10px;
|
| 80 |
}
|