nodejs send html file to client

后端 未结 3 1096
迷失自我
迷失自我 2021-01-30 17:10

I use this function to send html file to client, but in client I get nothing (blank page) without error. Something I wrong?, please help?

var express = require(\         


        
3条回答
  •  余生分开走
    2021-01-30 18:06

    you can render the page in express more easily

    
     var app   = require('express')();    
        app.set('views', path.join(__dirname, 'views'));
        app.set('view engine', 'jade');
     
        app.get('/signup',function(req,res){      
        res.sendFile(path.join(__dirname,'/signup.html'));
        });
    
    

    so if u request like http://127.0.0.1:8080/signup that it will render signup.html page under views folder.

提交回复
热议问题