Exemplo n.º 1
0
        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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
        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)
Exemplo n.º 4
0
def page_not_found(e):

    return resp(500)
Exemplo n.º 5
0
def page_not_found(e):

    return resp(405)
Exemplo n.º 6
0
def get_file(**kwargs):

    db = Database()
    response = db.GetFile()
    return resp(**response)