Skip to content

Commit

Permalink
fix http404 error (screenshot)
Browse files Browse the repository at this point in the history
  • Loading branch information
amerkurev committed Apr 24, 2023
1 parent 4914609 commit fca79ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scrapper/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 4 additions & 1 deletion scrapper/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def result_json(id):

@app.route('/screenshot/<string:id>', 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
Expand Down

0 comments on commit fca79ad

Please sign in to comment.