Apache + mod_wsgi + Flask (similar to Django) not working

I have a site written with the Python Framework flag (similar to Django), but I cannot deploy it with the instructions he gave (using Apache2 and mod_wsgi on an Ubuntu server). Right now, instead of showing web pages, the url just gives directories like ftp. Below is my websitename.wsgi file:

import sys
sys.path.insert(0, '/var/www/websitename')

from websitename import app as application

      

And below is the part I pasted into apache2.conf:

ServerName localhost

WSGIDaemonProcess websitename user=www-data group=www-data threads=5
WSGIScriptAlias /websitename /var/www/websitename/websitename.wsgi

<Directory /var/www/websitename >
    WSGIProcessGroup websitename
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>

      

And the / var / www / websitename directory looks like this:

/websitename
/websitename.py
/static
    /style.css
/templates
    layout.html
    index.html
    login.html
    ...
/scripts
    __init__.py
    somescript.py

      

Can anyone give any suggestions what the problem is? Apache.conf?

UPDATE: We received error messages as shown below. Any hints?

[Mon Mar 12 12:23:32 2012] [error] [client 157.55.17.200] File does not exist: /var/www/robots.txt
[Mon Mar 12 12:23:33 2012] [notice] caught SIGTERM, shutting down
[Mon Mar 12 12:23:34 2012] [warn] mod_wsgi: Compiled for Python/2.7.2rc1.
[Mon Mar 12 12:23:34 2012] [warn] mod_wsgi: Runtime using Python/2.7.2+.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31835): Starting process 'mywsgiapp' with uid=33, gid=33 and threads=5.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31835): Initializing Python.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31836): Initializing Python.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31837): Initializing Python.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31838): Initializing Python.
[Mon Mar 12 12:23:34 2012] [notice] Apache/2.2.20 (Ubuntu) PHP/5.3.6-13ubuntu3.6 with Suhosin-Patch mod_wsgi/3.3 Python/2.7.2+ configured -- resuming normal operations
[Mon Mar 12 12:23:34 2012] [info] Server built: Feb 14 2012 16:35:35
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31840): Initializing Python.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31839): Initializing Python.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31835): Attach interpreter ''.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31836): Attach interpreter ''.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31838): Attach interpreter ''.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31837): Attach interpreter ''.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31840): Attach interpreter ''.
[Mon Mar 12 12:23:34 2012] [info] mod_wsgi (pid=31839): Attach interpreter ''.
[Mon Mar 12 12:25:41 2012] [error] [client 128.192.240.] File does not exist: /var/www/favicon.ico
[Mon Mar 12 12:25:41 2012] [info] mod_wsgi (pid=13463): Initializing Python.
[Mon Mar 12 12:25:41 2012] [info] mod_wsgi (pid=13463): Attach interpreter ''.
[Mon Mar 12 12:26:27 2012] [error] [client 128.192.240.] File does not exist: /var/www/favicon.ico
[Mon Mar 12 12:26:27 2012] [info] mod_wsgi (pid=17315): Initializing Python.
[Mon Mar 12 12:26:27 2012] [info] mod_wsgi (pid=17315): Attach interpreter ''.
[Mon Mar 12 12:26:28 2012] [info] mod_wsgi (pid=17367): Initializing Python.
[Mon Mar 12 12:26:28 2012] [info] mod_wsgi (pid=17368): Initializing Python.
[Mon Mar 12 12:26:28 2012] [info] mod_wsgi (pid=17367): Attach interpreter ''.
[Mon Mar 12 12:26:28 2012] [info] mod_wsgi (pid=17368): Attach interpreter ''.
[Mon Mar 12 12:26:31 2012] [info] mod_wsgi (pid=17559): Initializing Python.
[Mon Mar 12 12:26:31 2012] [info] mod_wsgi (pid=17559): Attach interpreter ''.

      

+3


source to share


1 answer


I don't know if you check this. You have the following lines in your websitename.py

if __name__ == '__main__':
    app.run()

      

Except for the flask manual:



Problem : Application won't start, error shows SystemExit is being ignored. You have a call to app.run () in your application file that is not protected

if __name__ == '__main__': 
    condition.

      

Hope this helps.

+1


source







All Articles