Forum

You are not logged in.

#1 06-09-2017 14:01:47

wojtek
Membre
Registered: 11-05-2017
Posts: 5

Problem running python with wsgi

Hi,
So I've tried running a really simple script using wsgi and I can't get it working.

The script itself is located under `www/myapp`:

me@ssh2:~/www/myapp$ pwd
/home/me/www/myapp

and the code itself is really simple:

me@ssh2:~/www/myapp$ cat app.py
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]

    start_response(status, response_headers)

    return [output]

I've configured the env as follows:
address: me.alwaysdata.net/py
type: python wsgi
app path: /www/myapp/app.py
working directory: /www/myapp/
virt env: /myenv/ (not sure if needed, shouldn't)


Trying to access the url results in error:

$ curl http://me.alwaysdata.net/py/
curl: (18) transfer closed with 12 bytes remaining to read

and log says:

*** Operational MODE: preforking ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2283164)
spawned uWSGI worker 1 (pid: 2283171, cores: 1)
spawned 1 offload threads for uWSGI worker 1
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x10692f0 pid: 2283171 (default app)

I've tried googling but nothing relevant shows up and a couple of forum posts in the forum are in French and relate to django...

Offline

#2 06-09-2017 15:03:19

@Cyril
Staff
From: Paris
Registered: 06-02-2007
Posts: 5,558
Website

Re: Problem running python with wsgi

Hello,

Your application is not a valid Python 3 WSGI application. It should work in Python 2 though.

Offline

#3 06-09-2017 16:11:27

wojtek
Membre
Registered: 11-05-2017
Posts: 5

Re: Problem running python with wsgi

Thank you - after switching to python2 it works now!

Offline

Board footer

Powered by FluxBB