Commit
·
05501d1
1
Parent(s):
fd898ae
create wsgi server
Browse files- Dockerfile +1 -1
- app.py → server.py +12 -6
- wsgi.py +7 -0
Dockerfile
CHANGED
@@ -8,4 +8,4 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
8 |
|
9 |
COPY . .
|
10 |
|
11 |
-
CMD ["gunicorn", "-c", "gunicorn_config.py", "
|
|
|
8 |
|
9 |
COPY . .
|
10 |
|
11 |
+
CMD ["gunicorn", "-c", "gunicorn_config.py", "wsgi:app"]
|
app.py → server.py
RENAMED
@@ -7,7 +7,7 @@ import tempfile
|
|
7 |
|
8 |
def get_secrets(file):
|
9 |
file_path = f'/run/secrets/{file}'
|
10 |
-
|
11 |
try:
|
12 |
with open(file_path, 'r') as file:
|
13 |
secret_example = file.read()
|
@@ -18,11 +18,15 @@ def get_secrets(file):
|
|
18 |
except PermissionError:
|
19 |
print('Permission denied. Make sure you have the necessary permissions to read the file.')
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
app = Flask(__name__)
|
23 |
-
app.config['SESSION_COOKIE_SECURE'] = True # Requires HTTPS
|
24 |
-
app.config['SESSION_COOKIE_SAMESITE'] = 'None'
|
25 |
-
app.secret_key = get_secrets('secret_key')
|
26 |
|
27 |
|
28 |
# Function to apply transformation to specific columns
|
@@ -51,6 +55,8 @@ def page_not_found(error):
|
|
51 |
def display_transformed_csv():
|
52 |
|
53 |
access_token = get_secrets('GH_token')
|
|
|
|
|
54 |
benchmark_file_texteval = 'Miner_Benchmark.csv'
|
55 |
benchmark_file_agieval = 'miner_benchmark_AGIEval.csv'
|
56 |
benchmark_file = ''
|
@@ -96,7 +102,7 @@ def display_transformed_csv():
|
|
96 |
return "CSV file not found."
|
97 |
|
98 |
if __name__ == '__main__':
|
|
|
99 |
app.secret_key = get_secrets('secret_key')
|
100 |
-
|
101 |
app.run(debug=True, host='0.0.0.0', port=7860)
|
102 |
|
|
|
7 |
|
8 |
def get_secrets(file):
|
9 |
file_path = f'/run/secrets/{file}'
|
10 |
+
print('in get_secrets function')
|
11 |
try:
|
12 |
with open(file_path, 'r') as file:
|
13 |
secret_example = file.read()
|
|
|
18 |
except PermissionError:
|
19 |
print('Permission denied. Make sure you have the necessary permissions to read the file.')
|
20 |
|
21 |
+
def create_app():
|
22 |
+
app = Flask(__name__)
|
23 |
+
app.config['SESSION_COOKIE_SECURE'] = True # Requires HTTPS
|
24 |
+
app.config['SESSION_COOKIE_SAMESITE'] = 'None'
|
25 |
+
app.secret_key = get_secrets('secret_key')
|
26 |
+
return app
|
27 |
+
|
28 |
+
app = create_app()
|
29 |
|
|
|
|
|
|
|
|
|
30 |
|
31 |
|
32 |
# Function to apply transformation to specific columns
|
|
|
55 |
def display_transformed_csv():
|
56 |
|
57 |
access_token = get_secrets('GH_token')
|
58 |
+
app.secret_key = get_secrets('secret_key')
|
59 |
+
print(access_token)
|
60 |
benchmark_file_texteval = 'Miner_Benchmark.csv'
|
61 |
benchmark_file_agieval = 'miner_benchmark_AGIEval.csv'
|
62 |
benchmark_file = ''
|
|
|
102 |
return "CSV file not found."
|
103 |
|
104 |
if __name__ == '__main__':
|
105 |
+
app = create_app()
|
106 |
app.secret_key = get_secrets('secret_key')
|
|
|
107 |
app.run(debug=True, host='0.0.0.0', port=7860)
|
108 |
|
wsgi.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from server import create_app
|
2 |
+
|
3 |
+
if __name__ == '__main__':
|
4 |
+
create_app = create_app()
|
5 |
+
create_app.run()
|
6 |
+
else:
|
7 |
+
app = create_app()
|