docker fix

This commit is contained in:
vladimir.ferko 2024-04-10 11:24:16 +02:00
parent ab5031fa87
commit b666783b35
2 changed files with 22 additions and 13 deletions

View File

@ -6,8 +6,10 @@ COPY . /app/
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
RUN python initial.py ENV DB_URI="sqlite:///anot_db.db"
ENV SECRET_KEY="random_secret_key"
EXPOSE 5050 EXPOSE 5050
CMD ["python3", "app.py"] # CMD ["python3", "app.py"]
ENTRYPOINT ["tail", "-f", "/dev/null"]

View File

@ -1,6 +1,6 @@
from flask import Flask, render_template, request, redirect, flash, session, url_for from flask import Flask, render_template, request, redirect, flash, session, url_for
from models import db, Users, Annotations, Samples from models import db, Users, Annotations, Samples
from dotenv import load_dotenv # from dotenv import load_dotenv
from sqlalchemy.orm import aliased from sqlalchemy.orm import aliased
import sqlalchemy import sqlalchemy
import os import os
@ -8,12 +8,15 @@ import os
import logging import logging
load_dotenv() # load_dotenv()
app = Flask(__name__) app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DB_URI') # app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DB_URI')
app.secret_key = os.getenv('SECRET_KEY') # app.secret_key = os.getenv('SECRET_KEY')
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DB_URI']
app.secret_key = os.environ['SECRET_KEY']
db.init_app(app) db.init_app(app)
@ -104,12 +107,17 @@ def anot():
) )
sample_id, sample_text = query.one_or_none() sample_id, sample_text = query.one_or_none()
if sample_id:
data = { data = {
'email': session.get('email'), 'email': session.get('email'),
'text': sample_text, 'text': sample_text,
'sample_id': sample_id, 'sample_id': sample_id,
'annotated_count': annotated_count 'annotated_count': annotated_count
} }
else:
flash('Anotácia je dokončená')
return redirect('/')
except (sqlalchemy.exc.OperationalError) as err: except (sqlalchemy.exc.OperationalError) as err:
print(err) print(err)
@ -127,7 +135,6 @@ def anot():
def process(): def process():
if request.method == 'POST': if request.method == 'POST':
data = request.get_json() data = request.get_json()
print(data)
db.session.add(Annotations( db.session.add(Annotations(
user_id=session['id_user'], user_id=session['id_user'],
sample_id=data['sample_id'], sample_id=data['sample_id'],