NodeJS Rust 1.7中的Http_tiny不提供index.html *.js,*.css和静态页面中的图像

w9apscun  于 2023-06-29  发布在  Node.js
关注(0)|答案(1)|浏览(109)

伙计们,我的节点js的open-http服务器正在下降,包pkg创建exe。我尝试在rust 1.7中使用http_tiny,但无法运行服务器。我在windows10上使用基本rust gnu堆栈。你有任何想法如何使用http_tiny启动exe然后打开浏览器和服务文件夹./src2/index.html与所有 *.js *.css和 *.png和 *.jpg?我的意思是创建静态服务器与静态网页在生 rust ?

npm init

create index.js with init
npm install http-server
npm install pkg
npm install cli

to package json:
scripts{
"start": "http-server -o ./src"
},
 "bin" : "./bin/my-bin.js",

and to my-bin.js:

#!/usr/bin/env node
var join = require('path').join
var childProcess = require('child_process');
var args = process.argv.slice(2);

 args.unshift(__dirname + '/../'); 

childProcess.exec('npm start', (err, stdout) => {
if (err) console.log(err);
console.log(stdout);
})

command for exe:
pkg -t win .

不工作,尝试Rust ^我的Rust尝试被商店拒绝的npm:

rqdpfwrv

rqdpfwrv1#

现在我知道问题出在哪了我从node js使用pkg包,然后我使用NSIS 3从 *.zip创建安装程序,该程序在安装过程中解压缩到Program Files,然后图标启动器安装到Windows10,这是pkg的问题,它不是很好地解决路径,因为http服务器的每个html5文件使用相对路径,pkg正在解决图标启动器的绝对路径,并且无法读取本地文件夹src/index. html中的index. html,因为实际上它是IconLaunch/src/index. html,应用程序福尔斯。我有成千上万的路径相对定义,所以我不打算把它放到MS商店,我最好让它在本地文件夹的人免费使用这里:https://uloz.to/file/PRr28QEVvrMD/autoskola-free-2023-windows10-zip

相关问题