问题描述
我不是python专家。我正在尝试创建示例Web应用程序,并且可以使用flask运行它。但是,在打包并尝试使用服务员安装它之后,出现了错误-
没有名为helloweb.py的模块(这是我的Web应用程序)。我不确定如何解决此问题。任何指针都很棒。堆栈溢出的所有其他答案并没有太大帮助。
这是我的Web应用程序-
helloweb.py-
import datetime
from flask import Flask
from flask_api import status
import json
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello!'
@app.route('/xyz')
def display_status():
healthstatus=json.dumps({'status': status.HTTP_200_OK})
return healthstatus
我尝试了以下方法,并且有效-
FLASK_APP=helloweb.py
FLASK_RUN_PORT=8080
flask run
但是尝试将其移植到Wsgi生产服务器上的女服务员不适合我。我做了以下操作,创建了一个setup.py文件-
import setuptools
from setuptools import setup
with open("README.md","r") as fh:
long_description = fh.read()
setuptools.setup(
name="mydomain-webapp-myusername",# Replace with your own username
version="0.0.1",author="first.last",author_email="[email protected]",description="A small flask package",long_description="This is a web app",long_description_content_type="text/markdown",url="https://github.com/pypa/sampleproject",packages=setuptools.find_packages(),classifiers=[
"Programming Language :: Python :: 3","License :: OSI Approved :: MIT License","Operating Sy@R_404_6063@ :: OS Independent",],python_requires='>=3.6',)
,然后在与源文件(helloweb.py)相同的文件夹中创建了LICENSE README.md文件, init .py文件,waitress_server.py文件。我不确定为什么我在运行时会看到以下错误-
$ waitress-serve --call 'helloweb:app'
Error: Bad module 'helloweb'
Usage:
waitress-serve [OPTS] MODULE:OBJECT
.........
........
..........
There was an exception (ImportError) importing your module.
It had these arguments:
1. No module named flask_api
我能够在python shell和helloweb.py中导入flask_api,所以我不确定如何解决此问题。如何解决该错误?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)