ref: extract upload credentials into config

main^2
rrr-marble 4 years ago
parent 54a7010e76
commit 4b0b6ab9cc

@ -9,3 +9,7 @@ DATA_LOCATION = "/tmp/123"
DEST_SHRUNK = "image/"
# move originals here (needs to exist)
DEST_ORIGINAL = "original/"
# upload interface credentials
CRED_USERNAME="changeme"
CRED_PASSWORD="CHANGEME"

@ -11,7 +11,14 @@ import zipfile
# Global settings of this program
# ./config.py
from config import DB_LOCATION, DATA_LOCATION, DEST_SHRUNK, DEST_ORIGINAL
from config import (
DB_LOCATION,
DATA_LOCATION,
DEST_SHRUNK,
DEST_ORIGINAL,
CRED_USERNAME,
CRED_PASSWORD,
)
# our own util for photo upload and processing
@ -199,8 +206,8 @@ async def upload_pictures(
Пока исходим из предположения, что только я буду загружать фотографии.
"""
# check authenticity
correct_username = compare_digest(credentials.username, "1")
correct_password = compare_digest(credentials.password, "1")
correct_username = compare_digest(credentials.username, CRED_USERNAME)
correct_password = compare_digest(credentials.password, CRED_PASSWORD)
if not (correct_username and correct_password):
return JSONResponse(status_code=401)
# slurp the zip

Loading…
Cancel
Save