|
|
|
@ -1,9 +1,16 @@ |
|
|
|
# web_main.py |
|
|
|
from app import app |
|
|
|
from robyn import ALLOW_CORS # 导入跨域配置工具 |
|
|
|
import controller.GraphController |
|
|
|
import controller.LoginController |
|
|
|
import controller.OperationController |
|
|
|
from service.UserService import init_mysql_connection |
|
|
|
import os |
|
|
|
|
|
|
|
# 开启全局跨域支持,允许所有来源访问 |
|
|
|
# 这将解决浏览器报 "CORS error" 或请求被拦截的问题 |
|
|
|
ALLOW_CORS(app, ["*"]) |
|
|
|
|
|
|
|
# 添加静态文件服务 |
|
|
|
current_dir = os.path.dirname(os.path.abspath(__file__)) |
|
|
|
resource_dir = os.path.join(current_dir, "resource") |
|
|
|
@ -12,4 +19,7 @@ if os.path.exists(resource_dir): |
|
|
|
print(f"静态资源目录已配置: {resource_dir}") |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
init_mysql_connection() and app.start(host="0.0.0.0", port=8088) |
|
|
|
# 启动服务 |
|
|
|
# 确保 init_mysql_connection 返回 True 或者去掉 and 逻辑以保证 start 执行 |
|
|
|
init_mysql_connection() |
|
|
|
app.start(host="0.0.0.0", port=8088) |