Skip to content

Commit

Permalink
fixed urls for linux + enabled dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
KarinePistili committed Feb 22, 2022
1 parent 5510963 commit 9422693
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Binary file modified __pycache__/wsgi.cpython-38.pyc
Binary file not shown.
14 changes: 7 additions & 7 deletions app/routes/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def create_session():

# Check if extension is valid
if webcam_file and allowed_file(webcam_file.filename) and screen_file and allowed_file(screen_file.filename):
webcam_url = save_file_locally(webcam_file, f'\\{session_id}')
screen_url = save_file_locally(screen_file, f'\\{session_id}')
webcam_url = save_file_locally(webcam_file, f'/{session_id}')
screen_url = save_file_locally(screen_file, f'/{session_id}')
else:
return Response('Error: Files do not follow the extension guidelines', status=400, mimetype='application/json')

Expand All @@ -61,8 +61,8 @@ def create_session():
db.create_document(COLLECTION_NAME, session_id, session.to_dict())

# Generate csv dataset of calibration points
os.makedirs(f'{Path().absolute()}\\public\\training\\{session_id}\\', exist_ok=True)
csv_file = f'{Path().absolute()}\\public\\training\\{session_id}\\train_data.csv'
os.makedirs(f'{Path().absolute()}/public/training/{session_id}/', exist_ok=True)
csv_file = f'{Path().absolute()}/public/training/{session_id}/train_data.csv'
csv_columns = ['left_iris_x','left_iris_y','right_iris_x', 'right_iris_y', 'mouse_x', 'mouse_y']
try:
with open(csv_file, 'w') as csvfile:
Expand All @@ -74,8 +74,8 @@ def create_session():
print("I/O error")

# Generate csv of iris points of session
os.makedirs(f'{Path().absolute()}\\public\\sessions\\{session_id}\\', exist_ok=True)
csv_file = f'{Path().absolute()}\\public\\sessions\\{session_id}\\session_data.csv'
os.makedirs(f'{Path().absolute()}/public/sessions/{session_id}/', exist_ok=True)
csv_file = f'{Path().absolute()}/public/sessions/{session_id}/session_data.csv'
csv_columns = ['left_iris_x','left_iris_y','right_iris_x', 'right_iris_y']
try:
with open(csv_file, 'w') as csvfile:
Expand Down Expand Up @@ -150,4 +150,4 @@ def session_results_record():
if doc.exists:
session = doc.to_dict()

return send_file(f'{Path().absolute()}\\public\\videos\{session["screen_record_url"]}', mimetype='video/webm')
return send_file(f'{Path().absolute()}/public/videos/{session["screen_record_url"]}', mimetype='video/webm')
4 changes: 2 additions & 2 deletions app/services/gaze_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

def train_model(session_id):
# Download dataset
dataset_train_path = f'{Path().absolute()}\\public\\training\\{session_id}\\train_data.csv'
dataset_session_path = f'{Path().absolute()}\\public\\sessions\\{session_id}\\session_data.csv'
dataset_train_path = f'{Path().absolute()}/public/training/{session_id}/train_data.csv'
dataset_session_path = f'{Path().absolute()}/public/sessions/{session_id}/session_data.csv'

# Importing data from csv
raw_dataset = pd.read_csv(dataset_train_path)
Expand Down
5 changes: 3 additions & 2 deletions app/services/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
from pathlib import Path
import os

UPLOAD_FOLDER = f'{Path().absolute()}\\public\\videos'
UPLOAD_FOLDER = f'{Path().absolute()}/public/videos'

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER


def save_file_locally(file, folder):
# Create folder if does not exists
os.makedirs(UPLOAD_FOLDER+folder, exist_ok=True)
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER']+folder, filename))
return f'{folder}\{filename}'
return f'{folder}/{filename}'
2 changes: 1 addition & 1 deletion wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
})

if __name__ == "__main__":
app.run()
app.run(debug=os.environ['FLASK_ENV'])

0 comments on commit 9422693

Please sign in to comment.