Commit 9633ded 1 parent 664662c commit 9633ded Copy full SHA for 9633ded
File tree 4 files changed +22
-114
lines changed
4 files changed +22
-114
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,13 @@ ADD . /app
9
9
# Install any needed packages specified in requirements.txt
10
10
RUN pip install -r requirements.txt
11
11
12
- # Install Gunicorn
13
- RUN /bin/bash -c "source venv/bin/activate && pip install gunicorn"
14
-
15
12
# Make port 8000 available to the world outside this container
16
13
EXPOSE 8000
17
14
18
15
# Run main.py when the container launches
19
- CMD ["/bin/bash" , "-c" , "source venv/bin/activate && gunicorn src.app:app -b 0.0.0.0:8000" ]
16
+ # Add a shell script to run Uvicorn
17
+ ADD run.sh /run.sh
18
+ RUN chmod +x /run.sh
19
+
20
+ # Run the shell script when the container launches
21
+ CMD ["/run.sh" ]
Original file line number Diff line number Diff line change 1
- anyio == 4.3.0
2
- appnope == 0.1.4
3
- argon2-cffi == 23.1.0
4
- argon2-cffi-bindings == 21.2.0
5
- arrow == 1.3.0
6
- asttokens == 2.4.1
7
- async-lru == 2.0.4
8
- attrs == 23.2.0
9
- Babel == 2.14.0
10
- beautifulsoup4 == 4.12.3
11
- bleach == 6.1.0
12
- blinker == 1.8.1
13
- certifi == 2024.2.2
14
- cffi == 1.16.0
15
- charset-normalizer == 3.3.2
16
- click == 8.1.7
17
- comm == 0.2.2
18
- debugpy == 1.8.1
19
- decorator == 5.1.1
20
- defusedxml == 0.7.1
21
- exceptiongroup == 1.2.1
22
- executing == 2.0.1
23
- fastjsonschema == 2.19.1
24
- Flask == 3.0.3
25
- fqdn == 1.5.1
26
- h11 == 0.14.0
27
- httpcore == 1.0.5
28
- httpx == 0.27.0
29
- idna == 3.7
30
- importlib_metadata == 7.1.0
31
- ipykernel == 6.29.4
32
- ipython == 8.18.1
33
- isoduration == 20.11.0
34
- itsdangerous == 2.2.0
35
- jedi == 0.19.1
36
- Jinja2 == 3.1.3
37
- json5 == 0.9.25
38
- jsonpointer == 2.4
39
- jsonschema == 4.22.0
40
- jsonschema-specifications == 2023.12.1
41
- jupyter-events == 0.10.0
42
- jupyter-lsp == 2.2.5
43
- jupyter_client == 8.6.1
44
- jupyter_core == 5.7.2
45
- jupyter_server == 2.14.0
46
- jupyter_server_terminals == 0.5.3
47
- jupyterlab == 4.1.8
48
- jupyterlab_pygments == 0.3.0
49
- jupyterlab_server == 2.27.1
50
- MarkupSafe == 2.1.5
51
- matplotlib-inline == 0.1.7
52
- mistune == 3.0.2
53
- nbclient == 0.10.0
54
- nbconvert == 7.16.4
55
- nbformat == 5.10.4
56
- nest-asyncio == 1.6.0
57
- notebook_shim == 0.2.4
58
- numpy == 1.26.4
59
- overrides == 7.7.0
60
- packaging == 24.0
61
- pandas == 2.2.2
62
- pandocfilters == 1.5.1
63
- parso == 0.8.4
64
- pexpect == 4.9.0
65
- platformdirs == 4.2.1
66
- prometheus_client == 0.20.0
67
- prompt-toolkit == 3.0.43
68
- psutil == 5.9.8
69
- ptyprocess == 0.7.0
70
- pure-eval == 0.2.2
71
- pycparser == 2.22
72
- Pygments == 2.17.2
73
- python-dateutil == 2.9.0.post0
74
- python-json-logger == 2.0.7
75
- pytz == 2024.1
76
- PyYAML == 6.0.1
77
- pyzmq == 26.0.3
78
- referencing == 0.35.1
79
- requests == 2.31.0
80
- rfc3339-validator == 0.1.4
81
- rfc3986-validator == 0.1.1
82
- rpds-py == 0.18.0
83
- Send2Trash == 1.8.3
84
- six == 1.16.0
85
- sniffio == 1.3.1
86
- soupsieve == 2.5
87
- stack-data == 0.6.3
88
- terminado == 0.18.1
89
- tinycss2 == 1.3.0
90
- tomli == 2.0.1
91
- tornado == 6.4
92
- traitlets == 5.14.3
93
- types-python-dateutil == 2.9.0.20240316
94
- typing_extensions == 4.11.0
95
- tzdata == 2024.1
96
- uri-template == 1.3.0
97
- urllib3 == 2.2.1
98
- wcwidth == 0.2.13
99
- webcolors == 1.13
100
- webencodings == 0.5.1
101
- websocket-client == 1.8.0
102
- Werkzeug == 3.0.2
103
- zipp == 3.18.1
104
-
105
- python-dotenv
1
+ fastapi == 0.68.1
2
+ uvicorn == 0.15.0
3
+ python-dotenv == 0.19.1
4
+ requests == 2.26.0
5
+ jsonschema == 4.22.0
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ source venv/bin/activate
4
+ uvicorn src.app:app --host 0.0.0.0 --port 8000
Original file line number Diff line number Diff line change 1
- from flask import Flask , request
1
+ from fastapi import FastAPI , Request
2
2
import time
3
3
4
4
from src .data .Findings import Findings
7
7
8
8
import src .api .ollama as ollama
9
9
10
- app = Flask ( __name__ )
10
+ app = FastAPI ( )
11
11
12
12
start_time = time .time ()
13
13
@@ -33,12 +33,12 @@ def health():
33
33
34
34
35
35
@app .post ('/upload' )
36
- def upload ():
36
+ async def upload (request : Request ):
37
37
"""
38
38
This function takes the string from the request and converts it to a data object.
39
39
:return: 200 OK if the data is valid, 400 BAD REQUEST otherwise.
40
40
"""
41
- json_data = request .get_json ()
41
+ json_data = await request .json ()
42
42
# Check if the JSON data is valid
43
43
if not validate_json (json_data ):
44
44
return 'Invalid JSON data' , 400
@@ -77,4 +77,6 @@ def recommendations():
77
77
78
78
79
79
if __name__ == '__main__' :
80
- app .run (debug = True )
80
+ import uvicorn
81
+
82
+ uvicorn .run (app )
You can’t perform that action at this time.
0 commit comments