librelist archives

« back to archive

Upload file error with Nginx + uWsgi + Flask

Upload file error with Nginx + uWsgi + Flask

From:
G_will
Date:
2012-08-14 @ 16:42
Hi all,

I write some code about uploading files like this(
http://flask.pocoo.org/docs/patterns/fileuploads/), and I run them with
app.run(). It works. Files can be uploaded.
When I use Nginx + uWsgi + Flask, it seems OK when I request pages. But
when I upload file, it makes error like this:

Internal Server Error

The server encountered an internal error and was unable to complete your
request. Either the server is overloaded or there is an error in the
application.


My system is Ubuntu 12.04, the configs are:

@/etc/uwsgi/apps-enabled/uwsgi.ini

[uwsgi]
plugins=http,python
vhost=true
socket=127.0.0.1:9001

@/etc/nginx/sites-enabled/server
server {
    listen 80;
    server_name server.com;

    location /static {
        alias /path/to/static;
    }

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:9001;
        uwsgi_param UWSGI_PYHOME /path/to/virenv;
        uwsgi_param UWSGI_CHDIR /path/to/project;
        uwsgi_param UWSGI_MODULE module;
        uwsgi_param UWSGI_CALLABLE app;
    }

    error_page 404 /404.html;
}

What's wrong?

Sorry for my poor English.

Re: [flask] Upload file error with Nginx + uWsgi + Flask

From:
Roberto De Ioris
Date:
2012-08-16 @ 18:38
> Hi all,
>
> I write some code about uploading files like this(
> http://flask.pocoo.org/docs/patterns/fileuploads/), and I run them with
> app.run(). It works. Files can be uploaded.
> When I use Nginx + uWsgi + Flask, it seems OK when I request pages. But
> when I upload file, it makes error like this:
>
> Internal Server Error
>
> The server encountered an internal error and was unable to complete your
> request. Either the server is overloaded or there is an error in the
> application.
>
>
> My system is Ubuntu 12.04, the configs are:
>
> @/etc/uwsgi/apps-enabled/uwsgi.ini
>
> [uwsgi]
> plugins=http,python
> vhost=true
> socket=127.0.0.1:9001
>
> @/etc/nginx/sites-enabled/server
> server {
>     listen 80;
>     server_name server.com;
>
>     location /static {
>         alias /path/to/static;
>     }
>
>     location / {
>         include uwsgi_params;
>         uwsgi_pass 127.0.0.1:9001;
>         uwsgi_param UWSGI_PYHOME /path/to/virenv;
>         uwsgi_param UWSGI_CHDIR /path/to/project;
>         uwsgi_param UWSGI_MODULE module;
>         uwsgi_param UWSGI_CALLABLE app;
>     }
>
>     error_page 404 /404.html;
> }
>
> What's wrong?
>
> Sorry for my poor English.
>


You should check nginx error log

-- 
Roberto De Ioris
http://unbit.it

Re: [flask] Upload file error with Nginx + uWsgi + Flask

From:
Matt Wright
Date:
2012-08-16 @ 18:43
The Nginx log probably won't have much to speak of. Turn on debug mode:

    app.debug = True

and you should get a more detailed error.

On Thu, Aug 16, 2012 at 2:38 PM, Roberto De Ioris <roberto@unbit.it> wrote:

>
> > Hi all,
> >
> > I write some code about uploading files like this(
> > http://flask.pocoo.org/docs/patterns/fileuploads/), and I run them with
> > app.run(). It works. Files can be uploaded.
> > When I use Nginx + uWsgi + Flask, it seems OK when I request pages. But
> > when I upload file, it makes error like this:
> >
> > Internal Server Error
> >
> > The server encountered an internal error and was unable to complete your
> > request. Either the server is overloaded or there is an error in the
> > application.
> >
> >
> > My system is Ubuntu 12.04, the configs are:
> >
> > @/etc/uwsgi/apps-enabled/uwsgi.ini
> >
> > [uwsgi]
> > plugins=http,python
> > vhost=true
> > socket=127.0.0.1:9001
> >
> > @/etc/nginx/sites-enabled/server
> > server {
> >     listen 80;
> >     server_name server.com;
> >
> >     location /static {
> >         alias /path/to/static;
> >     }
> >
> >     location / {
> >         include uwsgi_params;
> >         uwsgi_pass 127.0.0.1:9001;
> >         uwsgi_param UWSGI_PYHOME /path/to/virenv;
> >         uwsgi_param UWSGI_CHDIR /path/to/project;
> >         uwsgi_param UWSGI_MODULE module;
> >         uwsgi_param UWSGI_CALLABLE app;
> >     }
> >
> >     error_page 404 /404.html;
> > }
> >
> > What's wrong?
> >
> > Sorry for my poor English.
> >
>
>
> You should check nginx error log
>
> --
> Roberto De Ioris
> http://unbit.it
>