Using node.js as a simple web server

后端 未结 30 2226
感情败类
感情败类 2020-11-22 02:54

I want to run a very simple HTTP server. Every GET request to example.com should get index.html served to it but as a regular HTML page (i.e., same

30条回答
  •  情话喂你
    2020-11-22 03:26

    if you have node installed on you PC probably you have the NPM, if you don't need NodeJS stuff, you can use the serve package for this:

    1 - Install the package on your PC:

    npm install -g serve
    

    2 - Serve your static folder:

    serve  
    d:> serve d:\StaticSite
    

    It will show you which port your static folder is being served, just navigate to the host like:

    http://localhost:3000
    

提交回复
热议问题