Python 未找到烧瓶剩余蓝图

Python 未找到烧瓶剩余蓝图,python,flask,flask-restful,Python,Flask,Flask Restful,我正在尝试将使用Flask、Blueprint和REST的应用程序拆分为不同的组件。但是我无法让api工作 结构如下: restml |-> __init__.py |-> app.py \-> resources |-> __init__.py \-> hello.py 我的restml/\uuuu init\uuuu.py是: from flask import Flask from flask_restful import Api from

我正在尝试将使用Flask、Blueprint和REST的应用程序拆分为不同的组件。但是我无法让api工作

结构如下:

restml
|-> __init__.py
|-> app.py
\-> resources
    |-> __init__.py
    \-> hello.py
我的
restml/\uuuu init\uuuu.py
是:

from flask import Flask
from flask_restful import Api

from restml.resources import hello

app = Flask(__name__)


app.register_blueprint(hello.blueprint)

if __name__ == '__main__':
    app.run(debug=True)
from flask_restful import Api, Resource, url_for
from flask import Blueprint

blueprint = Blueprint('hello', __name__)
api = Api()

class Hello(Resource):
    def get(self):
        return {
           "hello world"
        }

api.add_resource(Hello, '/api/hello', endpoint='hello')
我的
restml/resources/hello.py
是:

from flask import Flask
from flask_restful import Api

from restml.resources import hello

app = Flask(__name__)


app.register_blueprint(hello.blueprint)

if __name__ == '__main__':
    app.run(debug=True)
from flask_restful import Api, Resource, url_for
from flask import Blueprint

blueprint = Blueprint('hello', __name__)
api = Api()

class Hello(Resource):
    def get(self):
        return {
           "hello world"
        }

api.add_resource(Hello, '/api/hello', endpoint='hello')
当我运行应用程序时,所有内容都会启动,但是
curl
无法从url
http://localhost/api/hello

我应该如何调整文件以便找到RESTAPI

更新 添加后

import restml.resources.hello import blueprint
我得到以下错误

web_1    | Traceback (most recent call last):
web_1    |   File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
web_1    |     worker.init_process()
web_1    |   File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
web_1    |     self.load_wsgi()
web_1    |   File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
web_1    |     self.wsgi = self.app.wsgi()
web_1    |   File "/usr/local/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
web_1    |     self.callable = self.load()
web_1    |   File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
web_1    |     return self.load_wsgiapp()
web_1    |   File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
web_1    |     return util.import_app(self.app_uri)
web_1    |   File "/usr/local/lib/python3.5/site-packages/gunicorn/util.py", line 357, in import_app
web_1    |     __import__(module)
web_1    |   File "/usr/src/app/restml/__init__.py", line 4, in <module>
web_1    |     from web.restml.resources.hello import blueprint
web_1    | ImportError: No module named 'web'
web_1 |回溯(最近一次呼叫最后一次):
web|1|文件“/usr/local/lib/python3.5/site packages/gunicorn/arbiter.py”,第557行,在spawn|u worker中
web_1| worker.init_进程()
web|1|文件“/usr/local/lib/python3.5/site packages/gunicorn/workers/base.py”,第126行,在初始化过程中
web_1| self.load_wsgi()
web|1|文件“/usr/local/lib/python3.5/site packages/gunicorn/workers/base.py”,第136行,在load|wsgi中
web_1 | self.wsgi=self.app.wsgi()
web|1 |文件“/usr/local/lib/python3.5/site packages/gunicorn/app/base.py”,wsgi第67行
web_1 | self.callable=self.load()
web|1 |文件“/usr/local/lib/python3.5/site packages/gunicorn/app/wsgiapp.py”,第65行,已加载
web_1|返回self.load_wsgiapp()
web|1|文件“/usr/local/lib/python3.5/site packages/gunicorn/app/wsgiapp.py”,第52行,在load|wsgiapp中
web_1|返回util.import_应用程序(self.app_uri)
导入应用程序中的web|1 |文件“/usr/local/lib/python3.5/site packages/gunicorn/util.py”,第357行
web_1|_____导入__(模块)
web|1 |文件“/usr/src/app/restml/uuuu init_uuuu.py”,第4行,在
web_1 |来自web.restml.resources.hello导入蓝图
web_1 |导入错误:没有名为“web”的模块

您需要导入
restml/resources/hello.py中的
restml/\uuuu init\uuuuu.py

from restml/resources/hello.py import blueprint

应该有用

您需要将
restml/resources/hello.py
文件导入
restml/\uuuu init\uuuuu.py

from restml/resources/hello.py import blueprint

应该有用

我现在遇到以下错误,
importorror:没有名为“web”的模块
您需要python webpy包。我是web框架的新手,但这不是
flask
的竞争对手吗?是的。这是一个不同的框架。但是没有任何理由显示该错误。您能否显示错误日志的更详细视图,以帮助更好地调试。如果您能发现错误,那就太好了。我现在遇到以下错误,
ImportError:没有名为“web”的模块。
您需要python webpy包。我是web框架的新手,但这不是
flask
的竞争对手吗?是的。这是一个不同的框架。但是没有任何理由显示该错误。您是否可以显示错误日志的更详细视图,以帮助更好地调试。如果您能够发现错误,那就太好了。