Switched to environment variables

main
Jef Roosens 2021-12-30 21:18:12 +01:00
parent 70c480a7cd
commit afa7cf782d
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
1 changed files with 4 additions and 5 deletions

9
app.py
View File

@ -4,8 +4,8 @@ from pathlib import Path
from werkzeug.utils import secure_filename
import subprocess
UPLOAD_FOLDER = './data'
API_KEY = 'yeet'
UPLOAD_FOLDER = Path(os.environ['REPO_DIR']) / "pkgs"
API_KEY = os.environ['API_KEY']
ALLOWED_EXTENSIONS = {'pkg.tar.zst', 'pkg.tar.gz'}
app = Flask(__name__)
@ -46,7 +46,7 @@ def upload_file():
# Create path for file & check if it already exists
filename = secure_filename(file.filename)
path = Path(app.config['UPLOAD_FOLDER']) / 'pkgs' / filename
path = Path(app.config['UPLOAD_FOLDER']) / filename
if path.exists():
return {'message': 'File already exists.'}, 400
@ -57,7 +57,7 @@ def upload_file():
file.save(path)
# Run repo-add on the file
res = subprocess.run(["repo-add", path.parent.parent / "repo.db.tar.gz", path])
res = subprocess.run(["repo-add", path.parent / "repo.db.tar.gz", path])
if res.returncode != 0:
path.unlink()
@ -65,4 +65,3 @@ def upload_file():
return {'message': 'Failed to add file to repository.'}, 500
return {'message': 'Success.'}, 200