diff --git a/scrapper/cache.py b/scrapper/cache.py index 7c20d47..d8fc85f 100644 --- a/scrapper/cache.py +++ b/scrapper/cache.py @@ -36,4 +36,4 @@ def json_location(filename): def screenshot_location(filename): - return str(json_location(filename)) + '.' + SCREENSHOT_TYPE + return USER_DATA_DIR / '_res' / filename[:2] / (filename + '.' + SCREENSHOT_TYPE) diff --git a/scrapper/views.py b/scrapper/views.py index 3197d5c..01ecf0d 100644 --- a/scrapper/views.py +++ b/scrapper/views.py @@ -58,7 +58,10 @@ def result_json(id): @app.route('/screenshot/', methods=['GET']) def result_screenshot(id): - return send_file(screenshot_location(id), mimetype=f'image/{SCREENSHOT_TYPE}') + path = screenshot_location(id) + if not path.exists(): + return 'Not found', Status.NOT_FOUND + return send_file(path, mimetype=f'image/{SCREENSHOT_TYPE}') @app.route('/parse', methods=['GET']) # DEPRECATED