Pregunta

I have been trying to get Flask to work on my webfaction server for hours with no results.

I followed the instructions at http://flask.pocoo.org/snippets/65/

I have my index.py file stored under htdocs.

import sys
yourappname = "/home/<myusername>/webapps/myapp/htdocs"
if not yourappname in sys.path:
    sys.path.insert(0, yourappname)

from yourappname import app as application 

Then I have added this to my httpd.conf file:

WSGIPythonPath /home/yourusername/webapps/yourapp/htdocs/
#If you do not specify the following directive the app *will* work but you will
#see index.py in the path of all URLs
WSGIScriptAlias / /home/yourusername/webapps/yourapp/htdocs/index.py

<Directory /home/yourusername/webapps/yourapp/htdocs/>
   AddHandler wsgi-script .py
   RewriteEngine on
   RewriteBase /
   WSGIScriptReloading On
</Directory>

then i have myapp.py in the same htdocs directory next to index.py:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

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

I have my domain pointed to my project in webfaction. The default index.py was working prior to me overwriting with the new one as stated in the instructions. However, I only get the server 500. I apologize but I am a complete noob when it comes to linux and managing servers. I cannot even access my error log under users because it says I do not have permission.

I think that it has something to do with my installation of flask on the linux server, i installed it through easy install it says it installed all of the dependencies and did not give any errors.

¿Fue útil?

Solución

A couple of suggestions:

  1. Shouldn't you have myapp everywhere you have yourappname in your index.py?
  2. Also, I am assuming that you have made the appropriate substitutions in `WSGIPythonPath /home/yourusername/webapps/yourapp/htdocs
  3. Have you tried restarting the apache server by issuing a ~/webapps/<app_name>/apache2/bin/restart
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top