1

I'm working through a short Flask tutorial and am having some issues. I got to the end and got a 500 Server error. If I run the .fcgi from within my virtual environment I get the message below. I don't see any errors in logs I have access to. Not really sure what the problem is.

  • Shared host: Bluehost
  • Python ver: 2.7.6

Error message

(flask_hello_world) me@domain [~/public_html/projects/flask_hello_world]# python flask_hello_world.fcgi
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 12

Hello World!

.htaccess

Options +ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %(REQUEST_FILENAME) !-f
RewriteRule ^(.*)$ flask_hello_world.fcgi/$1 [QSA,L]
RewriteLog rewrite.log
RewriteLogLevel 3

flask_hello_world.fcgi

#!/path/to/python27/.virtenv/flask_hello_world/bin/python

from flup.server.fcgi import WSGIServer
from flask_hello_world_app import app as application

if __name__ == '__main__':
WSGIServer(application).run()

flask_hello_world_app.py

from datetime import datetime
from flask import Flask
app = Flask(__name__)

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

@app.route('/the-time')
def the_time():
     cur_time = str(datetime.now())
     return cur_time + ' is the current time!  ...YEAH!'

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

Packages Installed on /.virtenv/flask_hello_world

# pip list
Flask (0.10.1)
flup (1.0.2)
itsdangerous (0.23)
Jinja2 (2.7.1)
MarkupSafe (0.18)
pip (1.4.1)
setuptools (0.9.8)
Werkzeug (0.9.4)
wsgiref (0.1.2)
wanderingandy
  • 823
  • 1
  • 8
  • 16
  • So it's saying flup isn't installed? Have you checked to see if it is? ie ssh into your session and try `python import flup`? – Alex S Dec 05 '13 at 19:33
  • Sorry, I thought that was my problem at first and have changed the title to reflect the new issue. – wanderingandy Dec 05 '13 at 20:22
  • Where do you enter your server connection information? Sorry I'm not very familiar with Flask, but that seems to be the information it's looking for. Did you do everything listed on the tutorial exactly? Maybe start over and see if it fixes it? – Alex S Dec 05 '13 at 23:42
  • I did. In the tutorial after the 3 files were created everything worked. – wanderingandy Dec 06 '13 at 05:49
  • 1
    Are you sure you can't get a more thorough error log? Have you read [this page](https://my.bluehost.com/cgi/help/562)? – Alex S Dec 06 '13 at 16:10
  • I hadn't seen that specific page. I'll open a ticket with them and see what they provide. – wanderingandy Dec 06 '13 at 16:50

1 Answers1

1

Two issues were actually causing my issues.

  1. I used parentheses instead of curly brackets in the RewriteCond in my .htaccess file. This site helped point that out. http://www.lyxx.com/freestuff/002.html

  2. The shebang in flask_hello_world.fcgi was incorrect. After fixing the issue with .htaccess I still received an Internal Server Error. Accessing the flask_hello_world.fcgi file directly gave me the error that pointed out the path issue.

wanderingandy
  • 823
  • 1
  • 8
  • 16