2017-10-22 69 views
0

这是我的功能看起来怎么样:瓶智威汤逊 - 试图访问时,获得404/AUTH

# authenticate a user 
def authenticate(username, password): 

    userAuth = username_mapping.get(username, None) 
    if userAuth and userAuth.password == password: 
     return userAuth 

# identify user from a token 
def identity(payload): 
    user_id = payload['identity'] 
    return userid_mapping.get(user_id, None) 

但是,当我尝试张贴一些JSON数据给它,它给了我下面的错误:

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

可能是什么问题?

+0

你是怎么定义'@ app.route'和你用什么网址来做这个帖子的? –

+0

我把'@jwt_required()'放在我的'get'方法上面,并且使用url http:// 127.0.0.1/auth' – gambit2017

回答

0

你类似的东西:

@app.route('/auth', methods=['POST']) 

文件里面?

+0

不,它在我看到的示例中没有提及: https: //pythonhosted.org/Flask-JWT/ – gambit2017

+0

事实上,由于JWT_AUTH_URL_RULE已将其设置为其默认URL,因此在此上下文中并不需要。您能否发布有关您的脚本和HTTP状态代码的更多细节? –

+0

需要其他什么细节?只要我的代码包含上面的代码,我应该不能访问'/ auth'吗? – gambit2017

0

尝试用flask-jwt-extended代替。 Flask-jwt已经被放弃了多年。