py4web as a WSGI application

60 views
Skip to first unread message

Nico Zanferrari

unread,
Jan 24, 2021, 4:33:28 PM1/24/21
to py4web
Hi,

I was working for converting the main README.md file in the repo to the RST format when I've noticed the following paragraph:

****************************************************************************************************

WSGI

py4web is a WSGI application. To obtain the WSGI app simply do:

from py4web.core import wsgi
application = wsgi()

The wsgi function takes arguments with the same name as the command line arguments.


****************************************************************************************************

I've tested it with the current version and it gives: KeyError: 'apps_folder' . After some test I've found that the second line must be changed to:

  application = wsgi(apps_folder="apps")


Now I can see the application.routes values, but anyhow I'm not able to get a simple web output ;-( 

Can someone provide a simple working example of how to  use py4web as a WSGI application?  


Thank you,
Nico

Val K

unread,
Jan 24, 2021, 5:14:29 PM1/24/21
to py4web
You should pass it to wsgi server:
gunicorn example (using gunicorn-cli)

# py4web_wsgi.py 
from py4web.core import wsgi
myapp = wsgi(apps_folder="apps")  

#then start using cli
$ gunicorn -w 4 py4web_wsgi:myapp  

понедельник, 25 января 2021 г. в 00:33:28 UTC+3, nico...@gmail.com:

Nico Zanferrari

unread,
Jan 25, 2021, 4:19:55 PM1/25/21
to Val K, py4web
Thank you, Val.

This is exactly what I was searching for. I think I'll move this piece to the Chapter 2 (the installation one).

Nico

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/bd54f312-4cf3-4e71-b24b-4e70efbc275fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages