Python社区  »  docker

此代码的错误是什么“状态500,与docker核对时出现错误消息”

jane Kumar 2019 • 1 周前 • 16 次点击  

这是我的新快速应用程序的简单登录。但当我在邮递员身上测试时,我只收到500条状态信息。

我在堆栈溢出上尝试了所有操作

Route.js
{
var Express         = require("express");
var Routes          = Express.Router();
var UserRoute       = require('./src/User/User.Route');
var CommentRoute    = require('./src/Comment/Comment.Route');

Routes.use('/user/', UserRoute);
Routes.use('/comment/', CommentRoute);

module.exports = Routes;
}

app.js {

const Express       = require("express");
const BodyParser    = require("body-parser");
const Routes        = require("./Routes");
const Cors          = require("cors");

const app = Express();
app.use(Cors());

app.use(BodyParser.urlencoded({ extended: false }));
app.use(BodyParser.json());
app.use('/', Routes);

app.listen(8083, 'localhost', (err) => {
    if(err) {
        console.log(err);
        process.exit(-1);
    }
    console.log("Server listen port 8083");
});

}

这是路线。js页面我以前在这个项目中做路由

{
var mongoose        = require('mongoose');
const Schema        = mongoose.Schema;

const UserSchema = new Schema({
    userName: {
        type: String,
        require: true
    },
    password: {
        type: String,
        require: true
    }
});

mongoose.model('User', UserSchema);
mongoose.model('Comment', CommentSchema);

mongoose.connect('mongodb://localhost:27017/comments', (err) => {
    if (err) {
        console.log(err);
        process.exit(-1);
    }
    console.log('Connected to the DB');
});

module.exports = mongoose;
}

var express     = require('express');
var router      = express.Router();
var Controller  = require('./User.Controller');

router.post('/', (req, res) => {
    Controller.insert(req.body).then(data => {
        res.status(data.status).send({message: data.message});
    }).catch(err => {
        res.status(err.status).send({message: err.message});
    })
});


router.put('/:id', (req, res) => {
    Controller.update(req.params.id, req.body).then(data => {
        res.status(data.status).send({message: data.message});
    }).catch(err => {
        res.status(err.status).send({message: err.message});
    })
});

//控制器

var mongoose        = require('../DBSchema/SchemaMapper');
var UserSchema      = mongoose.model('User');

var UserController = function(){
    this.insert = (data) => {
        return new Promise((resolve, reject) => {
            var user = new UserSchema({
                userName: data.userName,
                password: data.password
            });
            user.save().then(() => {
                resolve({status: 200, message: "Added new user"});
            }).catch(err => {
                reject({status: 500, message: "Error:- "+err});
            })
        })

    }

this.searchAll = () => {
        return new Promise((resolve, reject) => {
            UserSchema.find().exec().then((data) => {
                resolve({status: 200, data: data});
            }).catch(err => {
                reject({status: 500, message: "Error:- " + err});
            })
        })
    }

我想知道如何在邮递员和语法上正确运行这个应用程序 错误。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56746
 
16 次点击  
分享到微博