Rewrite issue with configuring Lighttpd with Flask Python framework
Question: I've run and developed my Flask application without incident using its built-
in server. It has worked fine and has been really smooth and fun.
Unfortunately, Lighttpd is, as always, a pain to deploy to. I'm following the
instructions as closely as I can, but unfortunately, my application still
isn't working out.

Here is my configuration so far:

    
    
    server.modules   += ( "mod_fastcgi" )
    server.modules   += ( "mod_rewrite" )
    
    fastcgi.server = ("/bioinfo/main.fcgi" =>
        ((
            "socket" => "/tmp/bioinfo-fcgi.sock",
            "bin-path" => "/var/www/bioinfo/main.fcgi",
            "check-local" => "disable",
            "max-procs" => 1
        ))
    )
    fastcgi.debug = 1
    
    url.rewrite-once = (
        "^/bioinfo/static/(.*)$" => "/bioinfo/static/$1",
        "^/bioinfo/(.*)$" => "/bioinfo/main.fcgi/$1"
    )
    
    # in: /etc/lighttpd/conf-available/10-fastcgi.conf
    

This works in that it displays the main page, but not any subsequent pages.

I have several app.route handlers in my Flask application which I access using
either GET or POST using some XHR in the client.

Also, here's my .fcgi file, just to make sure I don't have any glaring errors
here:

    
    
    #!/usr/bin/python
    from flup.server.fcgi import WSGIServer
    from main import app
    
    if __name__ == '__main__':
        WSGIServer(app).run()
    

If anyone can identify the problem, being, AJAX doesn't work with the
application's URIs (most likely because my rewrite rules are wonky), I'd
really appreciate it. Thanks in advance, folks!


Answer: You need to chdir to the directory your application is running in manually.

