This returns a 500 error (doesn't work):
from pyadd.lib import addme
def application(environ, start_response):
q = environ['QUERY_STRING']
num1 = int(q[(q.index('=') + 1)])
num2 = int(q[(q.index('=',6) + 1)])
sum = str(addme(num1, num2))
start_response('200 OK', [('Content-Type', 'text/plain')])
return sum
This does work:
def application(environ, start_response):
q = environ['QUERY_STRING']
num1 = int(q[(q.index('=') + 1)])
num2 = int(q[(q.index('=',6) + 1)])
sum = str(num1 + num2)
start_response('200 OK', [('Content-Type', 'text/plain')])
return sum
This also works when run on the VPS independent of OLS:
from pyadd.lib import addme
q = "first=2&second=4"
num1 = int(q[(q.index('=') + 1)])
num2 = int(q[(q.index('=',6) + 1)])
sum = str(addme(num1, num2))
print(sum)
So it seems like there is no problem with the python (cffi) module itself adding the two numbers and returning an int and there is no problem getting the query string from OLS and there is no problem with the python code itself afaict. Does OLS not support importing modules into a WSGI file? I checked the PEP 3333 WSGI spec and it appears to be allowed. Is this a bug?
from pyadd.lib import addme
def application(environ, start_response):
q = environ['QUERY_STRING']
num1 = int(q[(q.index('=') + 1)])
num2 = int(q[(q.index('=',6) + 1)])
sum = str(addme(num1, num2))
start_response('200 OK', [('Content-Type', 'text/plain')])
return sum
This does work:
def application(environ, start_response):
q = environ['QUERY_STRING']
num1 = int(q[(q.index('=') + 1)])
num2 = int(q[(q.index('=',6) + 1)])
sum = str(num1 + num2)
start_response('200 OK', [('Content-Type', 'text/plain')])
return sum
This also works when run on the VPS independent of OLS:
from pyadd.lib import addme
q = "first=2&second=4"
num1 = int(q[(q.index('=') + 1)])
num2 = int(q[(q.index('=',6) + 1)])
sum = str(addme(num1, num2))
print(sum)
So it seems like there is no problem with the python (cffi) module itself adding the two numbers and returning an int and there is no problem getting the query string from OLS and there is no problem with the python code itself afaict. Does OLS not support importing modules into a WSGI file? I checked the PEP 3333 WSGI spec and it appears to be allowed. Is this a bug?
Last edited: