Topallaj Denis commited on
Commit
0beca83
1 Parent(s): 8d6ce18

fix endpoint query to form

Browse files
Files changed (3) hide show
  1. main.py +3 -6
  2. static/script.js +6 -6
  3. 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
- sequence: str,
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.getElementById("predict-form").addEventListener("submit", async (e) => {
4
  e.preventDefault();
5
- const sequence = document.getElementById("sequence").value;
6
- const smiles = document.getElementById("substrate").value;
7
 
8
  console.log(sequence);
9
 
10
  const data = await prediction(sequence, smiles);
11
 
12
- document.getElementById("km-result").innerText = data.km;
13
- document.getElementById("kcat-result").innerText = data.kcat;
14
- document.getElementById("vmax-result").innerText = data.vmax;
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
- /* style.css */
2
 
 
 
 
 
 
 
 
 
3
  body {
4
- font-family: Arial, sans-serif;
5
- margin: 0;
6
- padding: 0;
7
- background-color: #f4f4f4;
8
  }
9
 
10
  .container {
11
- max-width: 600px;
12
- margin: 20px auto;
13
- padding: 20px;
14
- background-color: #fff;
15
- border-radius: 8px;
16
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
17
  }
18
 
19
  h1 {
20
- text-align: center;
21
- margin-bottom: 20px;
22
  }
23
 
24
  p {
25
- margin-bottom: 20px;
26
  }
27
 
28
  form {
29
- margin-bottom: 20px;
30
  }
31
 
32
  label {
33
- display: block;
34
- margin-bottom: 5px;
35
  }
36
 
37
  input[type="text"] {
38
- width: 100%;
39
- padding: 10px;
40
- margin-bottom: 10px;
41
- border: 1px solid #ccc;
42
- border-radius: 5px;
43
  }
44
 
45
  input[type="submit"] {
46
- width: 100%;
47
- padding: 10px;
48
- background-color: #007bff;
49
- color: #fff;
50
- border: none;
51
- border-radius: 5px;
52
- cursor: pointer;
53
- transition: background-color 0.3s ease;
54
  }
55
 
56
  input[type="submit"]:hover {
57
- background-color: #0056b3;
58
- }
59
-
60
- #result-container {
61
- display: none; /* Hide result container initially */
62
  }
63
 
64
- #result {
65
- background-color: #f9f9f9;
66
- padding: 20px;
67
- border-radius: 8px;
 
 
68
  }
69
 
70
  #result h3 {
71
- margin-bottom: 10px;
 
72
  }
73
 
74
  #result p {
75
- margin-bottom: 15px;
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
  }