javascript - Express not working as expected -
i trying set react app express running. however, can't understand why won't load page want to
this app.js
:
var express = require('express'); var app = express(); app.use('/', express.static('public')); app.get('/', function(req, res) { res.sendfile('./index.html'); }); app.get('/canyouplay.js', function(req, res) { res.sendfile('/canyouplay.html'); }); app.listen(process.env.port || 8080);
this works. if change first app.get to:
app.get('/', function(req, res) { res.sendfile('./canyouplay.html'); });
it still renders same html file when restarting app though different files.
also when run function:
handleclick: function() { document.location.replace('./canyouplay'); },
it says cannot /canyouplay though html , js file exist name.
what have missed or doing wrong?
Comments
Post a Comment