zl程序教程

您现在的位置是:首页 >  后端

当前栏目

[Node.js]24. Level 5: Express, Express routes

JSNode 24 level Express routes
2023-09-14 09:00:56 时间

Create an express route that responds to GET requests at the URL /tweets that responds with the filetweets.html located in the same directory as app.js

Make sure you create the app and listen on port 8080

var express = require('express');
var app = express.createServer();

app.get('/tweets', function(request, response){
    response.sendfile(__dirname + "/tweets.html");
});

app.listen(8080);