首页 > 解决方案 > 不能 GET /Login 或更高版本不能 POST /Login

问题描述

请帮助,是使用express创建和提交一个html表单,但错误是Cannot GET /Login或更高版本的Cannot POST /Login

<form name="myForm" onsubmit="return validateForm()" method="POST" action="/login">
        Email <br><input type="email"name="email" required><br>
        Password <br><input type="Password"name="password" required><br>
        <input type="submit" value="Login">
        <input type="reset"><br>
        New to Soft Mak Finder? <a href="/Register">Register</a>
    </form>

无法使用快递发布/错误

这是我的js代码:

const path = require('path')
const express = require('express');
const app = express();              // to link html files from any other section
const bodyParser = require('body-parser');
const bcrypt=require('bcrypt-nodejs');




app.use(express.static(__dirname+"/public")); 
app.get('/',(req, res)=>{
    res.sendFile(path.join(__dirname+"/views/index.html")); 
})

app.get("/about",(req,res)=>{
  res.sendFile(path.join(__dirname+"/views/about.html"));
});
app.get("/notice",(req,res)=>{
  res.sendFile(path.join(__dirname+"/views/notice.html"));
});

app.post("/login",(req,res)=>{
  res.sendFile(path.join(__dirname+"/views/login.html"));
});
app.listen(5000,console.log("Server started...."));

我不断收到错误“无法发布/登录或无法获取/登录”

标签: htmlnode.jsexpress

解决方案


我检查了代码,它正在我的系统上运行


推荐阅读