def root_static_get(): file_name = flask.request.path.lstrip('/') if not file_name: file_name = 'index.html' cache = False else: cache = True static_file = StaticFile(app_server.www_path, file_name, cache=cache) return static_file.get_response()
def user_linked_key_page_get(view_id): view_id_key = 'view_token-%s' % view_id org_id = cache_db.dict_get(view_id_key, 'org_id') user_id = cache_db.dict_get(view_id_key, 'user_id') key_id = cache_db.dict_get(view_id_key, 'key_id') conf_urls = cache_db.dict_get(view_id_key, 'conf_urls') if conf_urls: conf_urls = json.loads(conf_urls) # Check for expire if not cache_db.exists(view_id_key): time.sleep(RATE_LIMIT_SLEEP) return flask.abort(404) org = Organization.get_org(id=org_id) user = org.get_user(user_id) key_page = StaticFile(app_server.www_path, KEY_INDEX_NAME, cache=False).data key_page = key_page.replace('<%= user_name %>', '%s - %s' % ( org.name, user.name)) key_page = key_page.replace('<%= user_key_url %>', '/key/%s.tar' % ( key_id)) if org.otp_auth: key_page = key_page.replace('<%= user_otp_key %>', user.otp_secret) key_page = key_page.replace('<%= user_otp_url %>', 'otpauth://totp/%s@%s?secret=%s' % ( user.name, org.name, user.otp_secret)) else: key_page = key_page.replace('<%= user_otp_key %>', '') key_page = key_page.replace('<%= user_otp_url %>', '') key_page = key_page.replace('<%= view_id %>', view_id) conf_links = '' for conf_url in conf_urls: conf_links += '<a class="sm" title="Download Mobile Key" ' + \ 'href="%s">Download Mobile Key (%s)</a><br>\n' % ( conf_url['url'], conf_url['server_name']) key_page = key_page.replace('<%= conf_links %>', conf_links) return key_page
def static_get(file_path): try: static_file = StaticFile(app_server.www_path, file_path, cache=True) except InvalidStaticFile: return flask.abort(404) return static_file.get_response()
def static_get(file_path): file_path = os.path.join(app_server.www_path, file_path) static_file = StaticFile(file_path, cache=True) return static_file.get_response()