gpt4 book ai didi

python - 导入 flask 企业时没有名为核心的模块

转载 作者:行者123 更新时间:2023-12-03 17:03:18 24 4
gpt4 key购买 nike

我写了一个 python 脚本来拥有一个带有 flask 的肥皂服务器,它就像 documentation说:

from time import ctime
from flask import Flask
from flaskext.enterprise import Enterprise


if __name__ == '__main__':
app = Flask(__name__)
enterprise = Enterprise(app)

class DemoService(enterprise.SOAPService):

@enterprise.soap(_returns=enterprise._sp.String)
def get_time(self):
return ctime()

但是当我运行程序时,它说:
Traceback (most recent call last):
File "D:/Workspace/src/flask_soap_server.py", line 3, in <module>
from flaskext.enterprise import Enterprise
File "C:\Python27\lib\site-packages\flaskext\enterprise.py", line 20, in <module>
from soaplib.core import Application
ImportError: No module named core

我还写了一个客户端来调用这个服务器的 WSDL 地址:
from flaskext.enterprise import Enterprise
from flask import Flask


if __name__ == '__main__':

app = Flask(__name__)
enterprise = Enterprise(app)
client = enterprise.connect_to_soap_service('http://192.168.20.232:8000/_enterprise/soap?wsdl')
@app.route('/time')
def index():
time = client.service.get_time()

最佳答案

肥皂库(https://github.com/soaplib/soaplib):

This project is discontinued. Please head over to github.com/arskom/spyne for the next version.



Flask Enterprise ( https://pypi.python.org/pypi/Flask-Enterprise):2011 年最新版本

也许是时候转移到更好的支持项目了:)

有一个 Spyne + Flask 示例: https://github.com/arskom/spyne/tree/master/examples/flask

关于python - 导入 flask 企业时没有名为核心的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30299322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com