python - 烧瓶蓝图不起作用(Python2)
问题描述
设置: 我正在尝试克隆 git项目(此处的所有代码)以在本地部署它并使其用于学术目的。到目前为止,我只在 Python 3 下使用过 Flask,但这个项目是使用 Python 2 在 Flask 上编写的。设置 virtualenv 后,安装所有要求我可以成功运行(python server.py)它并导航到索引页面。
问题:每当我尝试访问“localhost:5000/login”之类的页面时,我只能看到 404 错误“未找到”。查看代码,我看到它正在导入包含到“.../login”视图的路线的蓝图,但它没有达到显示它的地步。
项目结构如下所示:
.
├── API Documentation.md
├── app.py
├── app.pyc
├── data
│ ├── samples
│ │ ├── categories.txt
│ │ ├── domains.txt
│ │ ├── names.txt
│ │ ├── products.txt
│ │ └── surnames.txt
│ └── sql
│ └── schema-00.sql
├── Makefile
├── README.md
├── requirements.txt
├── server.py
├── sfec
│ ├── api
│ │ ├── base.py
│ │ ├── base.pyc
│ │ ├── decorators.py
│ │ ├── decorators.pyc
│ │ ├── fields.py
│ │ ├── fields.pyc
│ │ ├── __init__.py
│ │ ├── __init__.pyc
│ │ ├── order.py
│ │ ├── order.pyc
│ │ ├── product.py
│ │ ├── product.pyc
│ │ ├── user.py
│ │ └── user.pyc
│ ├── config.py
│ ├── config.pyc
│ ├── controllers
│ │ ├── decorators.py
│ │ ├── decorators.pyc
│ │ ├── __init__.py
│ │ ├── __init__.pyc
│ │ ├── order.py
│ │ ├── order.pyc
│ │ ├── user.py
│ │ └── user.pyc
│ ├── database
│ │ ├── __init__.py
│ │ ├── __init__.pyc
│ │ ├── runtime.py
│ │ ├── runtime.pyc
│ │ ├── settings.py
│ │ └── settings.pyc
│ ├── __init__.py
│ ├── __init__.pyc
│ └── models
│ ├── base.py
│ ├── base.pyc
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── order.py
│ ├── order.pyc
│ ├── product.py
│ ├── product.pyc
│ ├── user.py
│ ├── user.pyc
│ ├── views.py
│ └── views.pyc
├── sfecadmin.py
├── templates
│ └── index.html
├── tests
│ ├── __init__.py
│ └── user_test.py
├── tree.txt
└── uml_diagram.png
10 directories, 63 files
这就是在可执行 server.py(代码片段)中调用蓝图的方式:
from sfec.api.user import register_user_resource
from sfec.controllers.user import user_api
app.register_blueprint(user_api, url_prefix='/api')
并且 user.py 文件(./sfec/controllers/user.py)包含(代码片段):
user_api = Blueprint('user_api', __name__)
@user_api.route('/login', methods=['POST'])
def login():
print "login page"
"""Log the user in."""
store = get_default_store()
user = User.authenticate(store, request.form['email'],request.form['password'])
if user:
session['user'] = user.id
return user.json()
abort(403)
'login' 路由已创建,所以我希望在导航到 'localhost:500/login' 后会收到一些回复,至少是错误 403 或其他内容,但不是 404(未找到)错误。
你能帮我理解我错过了什么吗?我将非常感谢任何帮助。
解决方案
推荐阅读
- plugins - ansible 查找插件权限升级似乎不起作用
- python - 当套接字侦听积压较小时,Python 中的对等方重置连接
- javascript - 从网站共享时,如何让 Facebook 共享对话框在移动设备上使用 facebook 应用程序打开?
- asp.net - 没想到服务器 HTML 包含一个在- React Hybrid 中的 AdSense 广告
- json - 列表中的列表 json 在颤动中解析
- wordpress - Woocommerce 可下载产品链接到外部文件夹而不是文件下载
- reactjs - next js中两个页面之间的数据传输
- php - 按二维数组的第一个元素对数据进行分组 - PHP
- python - 我的 django api view.py 没有显示列表并创建新列表
- javascript - 如何将一个集合作为子集合复制到另一个集合中?角火/角/火库