apache - python3 - wsgi - very basic but complete example

1,099 views
Skip to first unread message

jack...@gmail.com

unread,
Jan 23, 2017, 3:06:08 PM1/23/17
to modwsgi

So I was advised to use wsgi instead of cgi, so I tried to set it up with following settings for a basic example, without Django or any other webframe:

specs:

  • linux Kubuntu, apache 2.4, python 3.5
  • apache is running, mod_wsgi installed and enabled
  • website files are in root/var/www/html/, I have sudo access to this folder
  • the python 3.5 path is usr/bin/env python3
  • the python script: "index.py, simplest of scripts, has been made executable
  • the python executable lives in root/var/www/scripts

Questions:

  • how do I make this function spit out it's result

  • what's the deal with this wsgi script? I have no need for that, I also do not want any wsgi extensions

  • what apache directive do I need to introduce to run a script
  • So where does the 'application' function live?

Really lost in this wsgi idea, some clarification might help

Jason Garber

unread,
Jan 23, 2017, 9:14:46 PM1/23/17
to Unknown
Did you happen to read the excellent docs on myd_wsgi?

It is NOT the same as cgi at all.  Nowhere near.  

If you wish to use python to power a Web page you need a way to "call" it.  CGI obviously can do this, albeit inefficiently amount other issues.

Wsgi is "Web server gateway interface".  The basic idea is to configure a web server (apache) with wsgi (mod_wsgi) and then point it to your whatever.wsgi script which contains your application function which is then called each time a request comes in.

Sugreat you find os packages for python and mod_wsgi and apache so they all play nice.

Then read the manual on configuring.

Also - a light framework like Flask will make development easy.

J

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+unsubscribe@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Graham Dumpleton

unread,
Jan 23, 2017, 9:26:28 PM1/23/17
to mod...@googlegroups.com
Would suggest they perhaps look at:


and this three part series to understand web server and relationship to WSGI.


Definitely agree about using Flask as well. Then look at using mod_wsgi.

Sorry for brief response. Off on a trip later today so any response from me will be delayed.

Graham

To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.

phong ungxuan

unread,
Jul 3, 2017, 11:57:39 AM7/3/17
to modwsgi

I hope that these information useful for you:
http://koo.fi/blog/2012/12/02/serving-python-scripts-with-apache-mod_wsgi-part-i/


and i developed a webpage ( SimplePypgadmin ) by modwgi script connect Postgresql follow this koo.fi blog :

https://simplepypgadmin.blogspot.com/

I used  beaker ( for session cookie) + webob ( for response and request) and of couse modwsgi + psycopg2 for connect with Postgresql on apache.
I did not use framework, it's difficult for me.
i want to build simple modwsgi script like php script on apache. Be cause it is easy for me.

wsgi is better than cgi.

I built a small webapp with python cgi, and then i change to wsgi.
wsgi is very strongly, fast and light.



Vào 03:06:08 UTC+7 Thứ Ba, ngày 24 tháng 1 năm 2017, jack sparrow đã viết:
Reply all
Reply to author
Forward
0 new messages