diff --git a/config.py b/config.py index 62eab32..5e5109b 100644 --- a/config.py +++ b/config.py @@ -11,5 +11,5 @@ DEST_SHRUNK = "image/" DEST_ORIGINAL = "original/" # upload interface credentials -CRED_USERNAME="changeme" -CRED_PASSWORD="CHANGEME" \ No newline at end of file +CRED_USERNAME = "changeme" +CRED_PASSWORD = "CHANGEME" diff --git a/main.py b/main.py index a6f68cc..8cf6443 100644 --- a/main.py +++ b/main.py @@ -188,7 +188,7 @@ async def photo_points(): for point in points ] @app.post( - "/upload_pictures/", + "/upload_pictures", responses={ 202: {"description": "Archive accepted into processing"}, 401: {"description": "Authentication is required to access this resource"}, @@ -200,10 +200,12 @@ async def upload_pictures( credentials: HTTPBasicCredentials = Depends(security), file: UploadFile = File(...), ): - """Интерфейс для загрузки фотографий""" - """Условно кладём в браузер zip с фотографиями и он их потихоньку ест. - Доступ к этому интерфейсу, наверное, лучше ограничить паролем или как-нибудь ещё. - Пока исходим из предположения, что только я буду загружать фотографии. + """Photo upload endpoint""" + """ + Accepts photo in zip archives with any internal directory structure + Valid uploads yield 202 status message and process photos in the background + Non-zip archives yeild 415 error + Upload is restricted by basic HTTP login, configurable in config.py """ # check authenticity correct_username = compare_digest(credentials.username, CRED_USERNAME) @@ -230,8 +232,8 @@ def unpack_pictures_zip(file: UploadFile, time): """ Unpack and process zip archived photo Extract pictures in the DATA_LOCATION/processing - #TODO: and feed them to util/import_photos.py - #TODO: Walk the nested DATA_LOCATION/processing ourselves + and feed them to util/import_photos.py + Walk the nested DATA_LOCATION/processing ourselves Uses: DB_LOCATION, DATA_LOCATION """ # we only call this function sporadically, so import here