[英]how to serve html file used in react in server
this is folder of code这是代码文件夹
I use node js and react to build a project I build design using react and controller to get data how I can serve html file in server so when run node server.js it open html page that I created I try this in server.我使用 node js 和 react 来构建一个项目我使用 react 和 controller 构建设计来获取数据如何在服务器中提供 html 文件,所以当运行 node server.js 时它打开我创建的 html 页面我在服务器中尝试这个。 js js
app.get('/english', function(req, res) {
res.send(path.join(__dirname + '/index.html'));
});
and when i run this route localhost:3000/english
i got this当我运行这条路线localhost:3000/english
我得到了这个
/home/projects/folder/folder2/myproject/index.html
Read the html file first.首先阅读html文件。 You could assign it to a variable first then before sending.您可以先将其分配给变量,然后再发送。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.