Graham i know you helped me a lot but my script cannot work if i don;t het this oe sorted out and i'am trying for hours allready.
Please do help.
I have 3 wsgi scripts listening on 3 locations. What i'm trying to run an wsgi script from within another wsgi script with the following statement.
page = 'clientele'
pdata = requests.get( 'http://superhost.gr/' + page )
pdata = pdata.text + counter
page = the location of another wsgi app.
The error i'am getting when for i.e i try to load http://superhost.gr/clientele
mod_wsgi (pid=7152): Exception occurred processing WSGI script '/home/nikos/public_html/app.py'
OSError: Apache/mod_wsgi failed to write response data: Broken pipe.
The other script by itself executes normally but NOT from within my app.py script.
Any ideas on how to execute a wsgi app (b) from within a wsgi app(a) and store the response as html data?
On 10 Sep 2018, at 11:52 am, Νίκος Βέργος <nikos.at....@gmail.com> wrote:Graham i know you helped me a lot but my script cannot work if i don;t het this oe sorted out and i'am trying for hours allready.
Please do help.
I have 3 wsgi scripts listening on 3 locations. What i'm trying to run an wsgi script from within another wsgi script with the following statement.
page = 'clientele' pdata = requests.get( 'http://superhost.gr/' + page ) pdata = pdata.text + counter
page = the location of another wsgi app.
The error i'am getting when for i.e i try to load http://superhost.gr/clientele
mod_wsgi (pid=7152): Exception occurred processing WSGI script '/home/nikos/public_html/app.py' OSError: Apache/mod_wsgi failed to write response data: Broken pipe.
The other script by itself executes normally but NOT from within my app.py script.
Any ideas on how to execute a wsgi app (b) from within a wsgi app(a) and store the response as html data?
--
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+u...@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.
You received this message because you are subscribed to a topic in the Google Groups "modwsgi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/modwsgi/lZDr6zKcyUg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to modwsgi+u...@googlegroups.com.
On 10 Sep 2018, at 8:34 pm, Νικόλαος Κούρας <ni...@superhost.gr> wrote:1) How do i enable flask so that errors are shown in the browser for m, so i dont have to tail -f error_log all the time?When i was using the flask development server i had thisapp.run( host='superhost.gr', port=5000, debug=True )Now i have commented this out becuas eitsw being run by mod_wsgi and its sending everythign to the error_log text file.
2) Regarding this code which not behalfing as it should@app.route( '/<page>' )@app.route( '/' )def index( page=None ):# read environmentpage = request.args.get('page', 'index.html')When i try via browser:'http://superhost.gr/' page variable equals to 'index.html''http://superhost.gr/something' page variable still equals to 'index.html'How is this possbile under mod_wsgi ?
Like this you mean? ialso moved static/ files inside the new wsgi/ directory because even with the directive in the alias home=/home/nikos/public_html templates could not be found
====================================
DocumentRoot /home/nikos/public_html
<Directory /home/nikos/public_html>
Require all granted
</Directory>
<Directory /home/nikos/public_html/wsgi>
Require all granted
</Directory>
WSGIDaemonProcess app user=nikos group=nikos
WSGIScriptAliasMatch ^/(?!phpmyadmin) /home/nikos/public_html/wsgi/app.py process-group=app application-group=%{GLOBAL}
WSGIDaemonProcess clientele user=nikos group=nikos
WSGIScriptAlias /clientele /home/nikos/public_html/wsgi/clientele.py process-group=clientele application-group=%{GLOBAL}
WSGIDaemonProcess downloads user=nikos group=nikos
WSGIScriptAlias /downloads /home/nikos/public_html/wsgi/downloads.py process-group=downloads application-group=%{GLOBAL}====================================
Still the ERROR remains the same after moving to wsgi/
[root@superhost public_html]# curl http://superhost.gr index.html
[root@superhost public_html]# curl http://superhost.gr/clientele index.html
As it shows even with an argument passed to the domain '/' page = request.args.get('page', 'index.html') returns the latter
Also:
application = Flask(__name__) app = application app.debug = True
Wont display error in browser but still in the error_log text file
DocumentRoot /home/nikos/public_html
<Directory /home/nikos/public_html>
Require all granted
</Directory>
<Directory /home/nikos/wsgi>
Require all granted
</Directory>
WSGIDaemonProcess app user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAliasMatch ^/(?!phpmyadmin) /home/nikos/public_html/wsgi/app.py process-group=app application-group=%{GLOBAL}
WSGIDaemonProcess clientele user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAlias /clientele /home/nikos/public_html/wsgi/clientele.py process-group=clientele application-group=%{GLOBAL}
WSGIDaemonProcess downloads user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAlias /downloads /home/nikos/public_html/wsgi/downloads.py process-group=downloads application-group=%{GLOBAL}=========================
I haven't understood your last mail.
@app.route( '/' )
@app.route( '/<page>' )
def index( page=None ):
# read environment
pdata = ''
page = request.args.get('page', 'index.html')
'page' variable is supposed to hold the URL parameter givn in browser as 'http://superhost.gr/something' no?!
It should instead be page = request.args.get(page, 'index.html') you mean?!
But why?!
On 10 Sep 2018, at 10:08 pm, Νικόλαος Κούρας <ni...@superhost.gr> wrote:/home/nikos/wsgi/ i places my apps and static remains at public_html Configuration now is:DocumentRoot /home/nikos/public_html <Directory /home/nikos/public_html> Require all granted </Directory> <Directory /home/nikos/wsgi> Require all granted </Directory> WSGIDaemonProcess app user=nikos group=nikos home=/home/nikos/public_html WSGIScriptAliasMatch ^/(?!phpmyadmin) /home/nikos/public_html/wsgi/app.py process-group=app application-group=%{GLOBAL} WSGIDaemonProcess clientele user=nikos group=nikos home=/home/nikos/public_html WSGIScriptAlias /clientele /home/nikos/public_html/wsgi/clientele.py process-group=clientele application-group=%{GLOBAL} WSGIDaemonProcess downloads user=nikos group=nikos home=/home/nikos/public_html WSGIScriptAlias /downloads /home/nikos/public_html/wsgi/downloads.py process-group=downloads application-group=%{GLOBAL}=========================I haven't understood your last mail.@app.route( '/' ) @app.route( '/<page>' ) def index( page=None ): # read environment pdata = '' page = request.args.get('page', 'index.html')
On 10 Sep 2018, at 11:16 pm, Νικόλαος Κούρας <ni...@superhost.gr> wrote:One *very* last thing please(you have been more than helpful !!):Having this:WSGIDaemonProcess clientele user=nikos group=nikos home=/home/nikos/wsgiWSGIScriptAlias /clientele /home/nikos/wsgi/clientele.py process-group=clientele application-group=%{GLOBAL}I cannot see to get a proper response when my app.py tries to load http://superhost.gr/clientele
if page in ('clientele', 'downloads'):try:r = requests.get( 'http://superhost.gr/' + page )if r.ok:pdata = r.text + counter
else:pdata = r.status_code
except:
pdata = "Error retrieving webpage!"Just this one please and iam done asking you!!
On 11 Sep 2018, at 12:23 am, Νικόλαος Κούρας <ni...@superhost.gr> wrote:First of all have a good night's sleep!! :-)The idea behind my code is to add a counter at the end of data of each html file and wsgi_mod file running:Counter is just adding that value bases on previous calculations.The problem is that every time i try to loadorwhich i already have in httpd.conf an open mod_wsgi process for those 2 python apps
So every time app.py tries via request object to get the response of another wsgi app its keeps waiting and waiting for a long time until i ctrl-cHow will i be able to open via request method a wsgi app and return it in the form of html data?=======================================================@app.route( '/' )@app.route( '/<page>' )def index( page='index.html' ):# read environmentpdata = ''if ('.html', 'clientele', 'downloads') in page:
init()database( page )cur.execute( '''SELECT hits FROM pages WHERE url = %s''', page )
pagehit = cur.fetchone()[0]
# pick random line from the quote text file & random mp3 from the the music folderquote = random.choice( list( open( '/home/nikos/public_html/data/private/quotes.txt', encoding='utf-8' ) ) )
music = random.choice( os.listdir( '/home/nikos/wsgi/static/mp3/' ) )# add counter to html template and start renderingcounter = '''<table bgcolor=black bordercolor=orangered><td><font size=3 color=lime> Αριθμός Επισκεπτών: </font></td> <td><a href="%s"><font size=3 color=plum> %s </font></a></td></table>''' % ( url_for('log', page=page), pagehit )if page in ('clientele', 'downloads'):try:r = requests.get( 'http://superhost.gr/' + page )if r.ok:pdata = r.text + counterexcept Exception:sys.exit(0)elif page.endswith( '.html' ):pdata = render_template( page, quote=quote, music=music, page=page, pagehit=pagehit ) + counterreturn pdata
The error_log complains that it cannot find the templates.
WSGIDaemonProcess clientele user=nikos group=nikos home=/home/nikos/wsgi
Also you told me to put
application = Flask(__name__) app = application app.debug = True
for seeing errors in browsers but this didnt not work, as i only see internal server eror and have to look via console
You received this message because you are subscribed to a topic in the Google Groups "modwsgi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/modwsgi/lZDr6zKcyUg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to modwsgi+u...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "modwsgi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/modwsgi/lZDr6zKcyUg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to modwsgi+u...@googlegroups.com.
Last time. From the Flask documentation:Set app.testing instead of app.debug and exceptions should propagate back to mod_wsgi and it will log it. You really should though read the Flask documentation on how to have it log exceptions itself.And make sure you use those print() statements I keep mentioning to add you own log message to track things though. So long as don't want to setup logging properly, and add your own, you will be in the dark.Good luck.