Using node.js as a simple web server

后端 未结 30 2797
感情败类
感情败类 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:18

    I'm not sure if this is exactly what you wanted, however, you can try changing:

    {'Content-Type': 'text/plain'}
    

    to this:

    {'Content-Type': 'text/html'}
    

    This will have the browser client display the file as html instead of plain text.

提交回复
热议问题