appModule.py
def appCallable(environ, start_response):
start_response(
'200 OK',
[('Content-Type', 'text/plain; charset=utf-8')]
)
return [
f'Hello world!\n\n' .encode('utf-8'),
f'PATH_INFO = {environ["PATH_INFO" ]}\n'.encode('utf-8'),
f'RAW_URI = {environ["RAW_URI" ]}\n'.encode('utf-8'),
f'HTTP_HOST = {environ["HTTP_HOST" ]}\n'.encode('utf-8'),
f'REMOTE_ADD = {environ["REMOTE_ADDR" ]}\n'.encode('utf-8'),
f'HTTP_X_REAL_IP = {environ["HTTP_X_REAL_IP"]}\n'.encode('utf-8'),
f'REMOTE_PORT = {environ["REMOTE_PORT" ]}\n'.encode('utf-8')
]
Starting the WSGI webserver
We start the WSGI webserver. The Gunicorn command line option -b
allows to specify the IP address and port where the server listens:
$ gunicorn -b 127.0.0.1:1234 appModule:appCallable