请问我这段代码有语法错误吗?

localhost:3000,localhost:3000/index和localhost:3000/list三个网址只能访问一个剩下的会显示已拒绝访问

img

//用于创建网站服务器的模块
const http = require('http');
//app对象就是网站服务器对象
const app = http.createServer();
//当客户端有请求来的时候
app.on('request', (req, res) => {
    //获取请求方式
    //req.method
    // console.log(req.method);

    //获取请求地址
    //req.url
    // console.log(req.url);

    if (req.url == '/index') {
        res.end('welcome to homepage');
    } else if (req.url == '/list') {
        res.end('welcome to listpage');
    } else {
        res.end('not found');
    }

    if (req.method == 'POST') {
        res.end('post');
    } else if (req.method == 'GET') {
        res.end('get');
    }
    // res.end('<h2>hello user</h2>')

});
//监听窗口
app.listen(3000);
console.log('网站服务器启动成功');

似乎直接停止了。app crashed

这不是程序冲突了嘛,上面你写的代码逻辑是如果你这个可以访问/list,那也就意味着 /index不可以访问其他同理,如果你访问一个正常再去访问另一个就会报错说程序冲突