ref: extract upload credentials into config

rrr-marble 5 years ago
parent b61689145a
commit ea9c05dcc0

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

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

Loading…
Cancel
Save