def decorated_function(*args, **kwargs): #episode_id = kwargs.get('episode_id') #post_id = kwargs.get('post_id') token = request.headers.get('token', None) get_json = request.get_json(force=True, silent=True) if get_json: request_params = get_json else: request_params = request.form #nanti kalau butuh pakai token if token is None: if no_auth: # kalau mengirimkan parameter no_auth # data token menjadi optional # request akan tetap diproses tanpa perlu data user return f(request_params=request_params, *args, **kwargs) else: return resp(401) # di sini mulai proses authentikasi token return f( request_params=request_params, *args, **kwargs)
def download_file(filename): '''url for download file''' try: return send_from_directory(app.static_folder,filename,as_attachment=True) except FileNotFoundError: return resp(404)
def decorated_function(*args, **kwargs): token = request.headers.get('token', None) get_json = request.get_json(force=True, silent=True) if get_json: request_params = get_json else: request_params = request.form if token is None: if no_auth: return f(request_params=request_params, *args, **kwargs) else: return resp(400) return f(request_params=request_params, *args, **kwargs)
def page_not_found(e): return resp(500)
def page_not_found(e): return resp(405)
def get_file(**kwargs): db = Database() response = db.GetFile() return resp(**response)