首页 > 解决方案 > 带有 Python 和 React.js 的单一可执行文件

问题描述

我有两个应用程序

标签: pythonpython-3.xreactjsexecutable

解决方案


你可以使用这个设计结构来解决这个问题,就像所有的langs一样,你需要将前端打包到你的后端项目的public文件夹中:

.
└── project_template/
    ├── server/
    └── static/
        ├── css/
        ├── images/
        └── js/

这个项目模板可以是一个 npm 存储库,您可以自定义脚本来启动您的项目。

带有 react 和 node 的示例(您可以在GitHub 上查看 peoject ):

{
  "name": "poker-hand-analyzer",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "install-frontend-dependencies": "cd ./frontend && yarn install",
    "install-backend-dependencies": "cd ./backend && yarn install",
    "install-dependencies": "yarn install-frontend-dependencies && yarn install-backend-dependencies && yarn install",
    "frontend": "cd ./frontend && yarn start",
    "backend": "cd ./backend && yarn start",
    "start": "concurrently \"yarn frontend\" \"yarn backend\""
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/brunoxd13/poker-hand-analyzer.git"
  },
  "author": "Bruno Russi Lautenschlager",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/brunoxd13/poker-hand-analyzer/issues"
  },
  "homepage": "https://github.com/brunoxd13/poker-hand-analyzer#readme",
  "dependencies": {
    "concurrently": "^4.1.0"
  }
}

推荐阅读