python - Serving a "Hello World" page using Flask and Apache/mod_wsgi on Ubuntu server -


note: i've found 5 questions regarding broken "hello world on flask/mod_wsgi" implementations. have looked through of them, , can't find solution own broken implementation. please don't hasty close question duplicate.

i'm administering cloud ubuntu vm. it's running lamp stack. in webroot i've got mediawiki , few html files http://pipad.org/ball/multiball.html -- running okay.

now i'm trying have http://pipad.org/foo serve page dynamically generated python backend, using flask , apache/mod_wsgi.

unfortunately navigating browser http://pipad.org/foo results in "url not found".

here files:

pi@pidroplet:~/web/piflask$ pwd /home/pi/web/piflask  pi@pidroplet:~/web/piflask$ ls -l total 24 -rw-r--r-- 1 root root  628 may 15 02:37 apache.conf -rwxrwxr-x 1 pi   pi    153 may 15 02:39 piflask.py -rwxrwxr-x 1 pi   pi    379 may 15 02:38 piflask.wsgi drwxrwxr-x 5 pi   pi   4096 may 14 09:06 venv 

piflask.py

from flask import flask app = flask(__name__)  @app.route('/') def hello_world():     return 'hello world!'  # if __name__ == '__main__': #    app.run() 

piflask.wsgi

# http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/#creating-a-wsgi-file # http://www.enigmeta.com/2012/08/16/starting-flask/  import os, sys  project_dir = '/home/pi/web/piflask'  activate_this = os.path.join(project_dir, 'bin', 'activate_this.py') execfile(activate_this, dict(__file__=activate_this)) sys.path.insert(0, project_dir)  piflask import app application 

apache.conf

pi@pidroplet:~/web/piflask$ cat apache.conf  # in http://wiki.apache.org/httpd/distrosdefaultlayout & find equiv /usr/local/apache2/conf/httpd.conf # me (ubuntu) it's /etc/apache2/apache2.conf # # append:  #    include /path/to/this/file  # http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/#configuring-apache <virtualhost *>     servername pipad.org      wsgidaemonprocess piflask user=pi group=pi threads=5     wsgiscriptalias /foo /home/pi/web/piflask/piflask.wsgi      <directory /home/pi/web/piflask>         wsgiprocessgroup piflask         wsgiapplicationgroup %{global}         order deny,allow         allow     </directory> </virtualhost> 

and per comment in above config file, ...

pi@pidroplet:~/web/piflask$ tail -n 2 /etc/apache2/apache2.conf   include /home/pi/web/piflask/apache.conf 

can see i'm missing?

you have set application_root variable '/foo' in flask config.

piflask.py

from flask import flask app = flask(__name__) app.config['application_root'] = '/foo'  @app.route('/') def hello_world():     return 'hello world!' 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -