flask返回404,即使url匹配

2024-04-25 06:41:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在写一个auth API。代码可在enter link description here中找到。我运行的脚本是授权服务器.py在示例目录中。然而,我总是得到404响应,即使它似乎与url_映射匹配。打印结果为:

<Config {'DEBUG': True, 'TESTING': False, 'PROPAGATE_EXCEPTIONS': None, 'PRESERVE_CONTEXT_ON_EXCEPTION': None, 'SECRET_KEY': 'mykey', 'PERMANENT_SESSION_LIFETIME': datetime.timedelta(31), 'USE_X_SENDFILE': False, 'LOGGER_NAME': '__main__', 'LOGGER_HANDLER_POLICY': 'always', 'SERVER_NAME': 'localhost.com', 'APPLICATION_ROOT': None, 'SESSION_COOKIE_NAME': 'session', 'SESSION_COOKIE_DOMAIN': None, 'SESSION_COOKIE_PATH': None, 'SESSION_COOKIE_HTTPONLY': True, 'SESSION_COOKIE_SECURE': False, 'SESSION_REFRESH_EACH_REQUEST': True, 'MAX_CONTENT_LENGTH': None, 'SEND_FILE_MAX_AGE_DEFAULT': datetime.timedelta(0, 43200), 'TRAP_BAD_REQUEST_ERRORS': False, 'TRAP_HTTP_EXCEPTIONS': False, 'EXPLAIN_TEMPLATE_LOADING': False, 'PREFERRED_URL_SCHEME': 'http', 'JSON_AS_ASCII': True, 'JSON_SORT_KEYS': True, 'JSONIFY_PRETTYPRINT_REGULAR': True, 'JSONIFY_MIMETYPE': 'application/json', 'TEMPLATES_AUTO_RELOAD': None, '__module__': 'Auth.config', 'MONGODB_HOST': 'localhost', 'MONGODB_DB': 'flaskAuth', 'MONGODB_PORT': '27017', 'MONGODB_USERNAME': None, 'MONGODB_PASSWORD': None, 'EMAIL_SALT': 'email', 'MAIL_SERVER': 'smtp.126.com', 'MAIL_USERNAME': 'youraccount', 'MAIL_PASSWORD': 'yourpassword', 'MAIL_DEFAULT_SENDER': 'youraccount@126.com', '__dict__': <attribute '__dict__' of 'Config' objects>, '__weakref__': <attribute '__weakref__' of 'Config' objects>, '__doc__': None}>
Map([<Rule '/auth/http/updatepassword' (OPTIONS, POST) -> Auth.http_update_password>,
 <Rule '/auth/http/updateemail' (OPTIONS, POST) -> Auth.http_update_email>,
 <Rule '/auth/http/sendemail' (OPTIONS, POST) -> Auth.http_send_email>,
 <Rule '/auth/http/register' (OPTIONS, POST) -> Auth.http_register>,
 <Rule '/auth/http/logout' (OPTIONS, POST) -> Auth.http_logout>,
 <Rule '/auth/http/login' (OPTIONS, POST) -> Auth.http_login>,
 <Rule '/' (OPTIONS, HEAD, GET) -> home>,
 <Rule '/auth/http/emailactivate/<email_token>/' (OPTIONS, HEAD, GET) -> Auth.http_email_activate>,
 <Rule '/static/<filename>' (OPTIONS, HEAD, GET) -> static>])
 * Debugger is active!
 * Debugger PIN: 165-506-181
127.0.0.1 - - [25/Mar/2017 15:03:56] "GET / HTTP/1.1" 404 -

即使我只返回“/”中的字符串,它仍然返回404。在


Tags: noneauthfalsetruehttpgetemailcookie