flask_mongoengine.ValidationError不通过Nginx闪烁警告-错误的网关502

时间:2019-03-20 20:08:40

标签: nginx uwsgi supervisord flask-admin flask-mongoengine

我正在为数据库模型使用flask_mongoengine.ValidationError,在clean方法中使用它,以便在单击save选项时可以闪烁警告。当我在独立flask服务器上运行时,它工作得很好,但是当与nginx 502 bad gateway运行时,它给出了flask + uwsgi + nginx

我正在使用flask-adminadmin.add_view(...)来显示模型,请有人帮忙解决此问题,或者是否有其他方法可以通过验证数据向用户显示Flash消息保存。

class Test(db.Document):
    name = db.StringField(max_length=128, required=True, verbose_name='Name')
    ...
    ...

    def clean(self):
        if condition:
            msg = 'Atleast One Option has to be selected.'
            raise ValidationError(msg)

    def save(self, *args, **kwargs):
        return super(Test, self).save()

nginx配置为

server {
    listen      5000;
    server_name localhost;
    charset     utf-8;
    client_max_body_size 75M;


    location / {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/my_app/uwsgi.sock;
    }
}

supervisord.conf文件

[supervisord]
nodaemon=true

[program:nginx]
command=/usr/sbin/nginx

[program:uwsgi]
command =/usr/local/bin/uwsgi --ini  /etc/uwsgi/uwsgi.ini

0 个答案:

没有答案