即使URL匹配,flask也会返回404

时间:2017-03-25 07:06:52

标签: python flask

我一直在编写auth API。这些代码可在enter link description here中找到。我运行的脚本是示例目录中的authserver.py。但是,我总是得到404响应,即使它似乎与url_map匹配。打印结果是:

<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。

0 个答案:

没有答案