Topallaj Denis commited on
Commit
f594ac0
·
1 Parent(s): 89c6b6a

changed endpoint

Browse files
Files changed (4) hide show
  1. main.py +0 -8
  2. static/index.html +0 -49
  3. static/script.js +0 -28
  4. static/styles.css +0 -80
main.py CHANGED
@@ -1,7 +1,4 @@
1
  from fastapi import FastAPI
2
- from fastapi.middleware.cors import CORSMiddleware
3
- from fastapi.responses import FileResponse
4
- from fastapi.staticfiles import StaticFiles
5
  from typing import Dict, List, Any, Tuple
6
  import pickle
7
  import math
@@ -17,7 +14,6 @@ import pydantic
17
 
18
  app = FastAPI()
19
 
20
- app.mount("/", StaticFiles(directory="static", html=True), name="static")
21
  """
22
  tokenizer = T5Tokenizer.from_pretrained(
23
  "Rostlab/prot_t5_xl_half_uniref50-enc", do_lower_case=False, torch_dtype=torch.float16)
@@ -31,10 +27,6 @@ class Item(pydantic.BaseModel):
31
  smiles: str
32
 
33
  @app.get("/")
34
- def index() -> FileResponse:
35
- return FileResponse(path="/app/static/index.html", media_type="text/html")
36
-
37
- @app.post("/")
38
  def predict(item: Item):
39
 
40
  endpointHandler = EndpointHandler()
 
1
  from fastapi import FastAPI
 
 
 
2
  from typing import Dict, List, Any, Tuple
3
  import pickle
4
  import math
 
14
 
15
  app = FastAPI()
16
 
 
17
  """
18
  tokenizer = T5Tokenizer.from_pretrained(
19
  "Rostlab/prot_t5_xl_half_uniref50-enc", do_lower_case=False, torch_dtype=torch.float16)
 
27
  smiles: str
28
 
29
  @app.get("/")
 
 
 
 
30
  def predict(item: Item):
31
 
32
  endpointHandler = EndpointHandler()
static/index.html DELETED
@@ -1,49 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <script src="./script.js" defer></script>
7
- <link rel="stylesheet" href="./styles.css" />
8
-
9
- <title>UniKP App</title>
10
- </head>
11
- <body>
12
- <div class="container">
13
- <h1>UniKP App</h1>
14
- <p>
15
- This HF app uses the UniKP framework. Be sure to check it out on
16
- <a href="https://github.com/Luo-SynBioLab/UniKP"> GitHub</a>
17
- </p>
18
- <form id="predict-form">
19
- <label for="sequence">Sequence:</label>
20
- <input
21
- type="text"
22
- id="sequence"
23
- name="sequence"
24
- placeholder="Enter sequence here"
25
- required
26
- />
27
- <label for="substrate">Substrate (SMILES):</label>
28
- <input
29
- type="text"
30
- id="substrate"
31
- name="smiles"
32
- placeholder="Enter substrate SMILES here"
33
- required
34
- />
35
- <input type="submit" value="Predict" />
36
- </form>
37
- </div>
38
- <div id="result-container">
39
- <div id="result" class="container">
40
- <h3>Km</h3>
41
- <p id="km-result"></p>
42
- <h3>Kcat</h3>
43
- <p id="kcat-result"></p>
44
- <h3>Vmax</h3>
45
- <p id="vmax-result"></p>
46
- </div>
47
- </div>
48
- </body>
49
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/script.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- document.querySelector("#predict-form").addEventListener("submit", async (e) => {
4
- e.preventDefault();
5
-
6
- const sequence = document.querySelector("#sequence").value;
7
- const smiles = document.querySelector("#substrate").value;
8
-
9
- const data = await prediction(sequence, smiles);
10
-
11
- document.querySelector("#km-result").innerText = data.km;
12
- document.querySelector("#kcat-result").innerText = data.kcat;
13
- document.querySelector("#vmax-result").innerText = data.vmax;
14
-
15
- });
16
-
17
- const prediction = async (sequence, smiles) => {
18
-
19
- const response = await fetch("/", {
20
- method: "POST",
21
- body: {
22
- sequence: sequence,
23
- smiles: smiles,
24
- }
25
- });
26
- const data = await response.json();
27
- return data;
28
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/styles.css DELETED
@@ -1,80 +0,0 @@
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
- }