Skip to content

Commit 074012a

Browse files
committed
amend paths
1 parent 9d7172c commit 074012a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/app.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
app = Flask(__name__)
88
CORS(app)
99

10-
# Set absolute paths for the data
11-
csv_file_path = '/data/beol.csv' # Absolute path to CSV in Docker
10+
# Set relative paths for the data
1211
project = '0801'
13-
data_folder = '/data/0801' # Absolute path to project-specific data directory
12+
base_dir = os.path.dirname(__file__)
13+
csv_file_path = os.path.join(base_dir, '..', 'data', 'beol.csv') # Relative path to CSV
14+
data_folder = os.path.join(base_dir, '..', 'data', project) # Relative path to project-specific data directory
1415
file_generation_enabled = True
1516

1617
# Ensure 'data/0801' directory exists
@@ -24,7 +25,7 @@ def index():
2425

2526
if request.method == 'POST' and file_generation_enabled:
2627
manifest_server = request.form['manifest_server']
27-
script_command = f'python /src/beol-iiif.py --csv "{csv_file_path}" --manifest_server "{manifest_server}"'
28+
script_command = f'python {os.path.join(base_dir, "beol-iiif.py")} --csv "{csv_file_path}" --manifest_server "{manifest_server}"'
2829

2930
# Execute the script and capture output
3031
result = subprocess.run(script_command, shell=True, capture_output=True, text=True)
@@ -65,16 +66,19 @@ def toggle_generation():
6566

6667
@app.route('/amend-json', methods=['POST'])
6768
def amend_json():
68-
script_command = 'python /src/replace-sipi-url.py'
69+
script_command = f'python {os.path.join(base_dir, "replace-sipi-url.py")}'
6970
subprocess.run(script_command, shell=True)
7071
return redirect(url_for('index'))
7172

7273
@app.route(f'/data/{project}/<path:filename>')
7374
def serve_data(filename):
7475
if filename.endswith('.DS_Store'):
7576
return "Access denied", 403 # Block access to .DS_Store files
76-
return send_from_directory('/data/0801', filename)
77+
return send_from_directory(data_folder, filename)
7778

7879
if __name__ == '__main__':
79-
ssl_context = ('/certs/cert.pem', '/certs/key.pem') # Correct path to SSL certificates
80+
ssl_context = (
81+
os.path.join(base_dir, '..', 'certs', 'cert.pem'),
82+
os.path.join(base_dir, '..', 'certs', 'key.pem')
83+
) # Correct path to SSL certificates
8084
app.run(debug=True, ssl_context=ssl_context, host='0.0.0.0', port=5000)

0 commit comments

Comments
 (0)