Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 express 我们可以轻松地调用函数 get() ,如下所示:
var app = express(); app.get('/',function(req,res){ // do stuff })
node.js 中的等价物是什么?那么我怎么能在没有 express 的情况下做同样的事情呢?
我想这是你可以做这样的事情的方式
var http = require('http'); http.createServer(function (req, res) { if(req.method === 'GET' && req.path === '/'){ // do stuff } }).listen(8080, "127.0.0.1");