Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@eel.btl.route('/authorize')
def _authorize_rmd_token():
state = eel.btl.request.query.state
print('New refresh code request: ', state, eel.btl.request.query.code)
if state.strip() == settings.get('auth.oauth_key').strip():
code = eel.btl.request.query.code
print('Saving new reddit code.')
refresh = praw_wrapper.get_refresh_token(code)
if refresh:
settings.put('auth.refresh_token', refresh)
praw_wrapper.init()
praw_wrapper.login()
return 'Saved authorization token! Close this page to continue.'
return 'Cannot save the new auth key, something went wrong.<br><a href="../index.html">Back</a>'
@eel.btl.route('/file')
def _downloaded_files():
""" Allows the UI to request files RMD has scraped.
In format: "./file?id=file_token"
"""
token = eel.btl.request.query.id
file_obj = _session.query(sql.File).filter(sql.File.id == token).first()
file_path = file_obj.path
response = eel.btl.static_file(file_path, root=os.path.abspath(settings.get("output.base_dir")))
response.set_header("Cache-Control", "public, max-age=0")
return response