我对我的应用程序进行了全面测试,现在正在尝试将其部署在 A2 共享主机 - cPanel 上。我已经解决了一些初始问题,但我仍然坚持:即使我按照所有步骤将应用程序开发为一个包(在我的机器上本地),我仍然收到一个错误,即应用程序的名称不是在导入过程中被识别为包。
App 30622 output: File "__init__.py", line 77, in <module>
App 30622 output:
App 30622 output: from rem import routes
App 30622 output: ModuleNotFoundError
App 30622 output: : No module named 'rem'
rem
是我的包的名称。这一切都在当地起到了很好的作用,所以我不明白我做错了什么。我如何部署它?
import os
from flask import Flask
from flask_bcrypt import Bcrypt
from flask_login import LoginManager
from flask_sqlalchemy import SQLAlchemy
import yaml, logging
class UserPermission():
def getRoles(self, routeName):
if (routeName == "properties") or \
(routeName == "property_details") or \
(routeName == "update_property") or \
(routeName == "add_property") or \
(routeName == "delete_property"):
roles = ["Admin", "Director", "Manager"]
elif (routeName == "agents") or \
(routeName == "update_agent") or \
(routeName == "add_agent") or \
(routeName == "delete_agent"):
roles = ["Admin", "Director", "Manager"]
elif (routeName == "suppliers") or \
(routeName == "supplier_details") or \
(routeName == "update_supplier") or \
(routeName == "add_supplier") or \
(routeName == "delete_supplier"):
roles = ["Admin", "Director", "Manager"]
elif (routeName == "tenants") or \
(routeName == "tenant_details") or \
(routeName == "update_tenant") or \
(routeName == "add_tenant") or \
(routeName == "delete_tenant"):
roles = ["Admin", "Director", "Manager"]
elif (routeName == "maintenance_requests") or \
(routeName == "manage_maintenance_request") or \
(routeName == "maintenance_request_details") or \
(routeName == "delete_maintenance_request"):
roles = ["Admin", "Director", "Manager", "Agent"]
elif routeName == "new_maintenance_request":
roles = ["Admin", "Tenant"]
elif routeName == "landlords":
roles = ["Admin", "Director", "Manager"]
elif routeName == "appliances":
roles = ["Admin", "Director", "Manager", "Agent"]
elif (routeName == "new_job_order"):
roles = ["Admin", "Director", "Manager", "Agent"]
elif (routeName == "manage_job_order"):
roles = ["Admin", "Supplier"]
elif (routeName == "manage_job_orders") or \
(routeName == "job_order_details"):
roles = ["Admin", "Director", "Manager", "Agent", "Supplier"]
elif (routeName == "account_info"):
roles = ["Admin", "Director", "Manager", "Agent", "Tenant", "Supplier"]
else:
roles = ["Any"]
return roles
project_root = os.path.dirname(os.path.realpath('__file__'))
template_path = os.path.join(project_root, 'app/templates')
static_path = os.path.join(project_root, 'app/static')
app = Flask(__name__, template_folder=template_path, static_folder=static_path)
# Configure secret key
app.config["SECRET_KEY"] = "f9b7e0714b071f9b39a5fe1c47ae58b0"
# Configure DB
dbConfig = yaml.load(open("rem/db.yaml"), Loader = yaml.SafeLoader)
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://" + dbConfig["mysql_user"] + ":" + dbConfig["mysql_password"] + \
"@" + dbConfig["mysql_host"] + "/" + dbConfig["mysql_db"]
#Configure debug logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
bcrypt = Bcrypt(app)
loginManager = LoginManager(app)
db = SQLAlchemy(app)
userPermissions = UserPermission()
from rem import routes