# Path: app.py



import os
import sys
from flask import request, Response
from app import app
Modify your webapps/yourapp/apache2/conf/httpd.conf. At the bottom of the file add the following lines changing yourapp and yourusername according to your setup:
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>
If you have choosed / as the mout point for your application you are done. If you mounted the application somewhere else (i.e. /blog) there is some additional work to do.

You need to write a WSGI middleware that prefixes SCRIPT_NAME with that prefix otherwise the url_for function will not be able to create the correct URLs for you (the following snippets is kindly provided by Armin himself).

class WebFactionMiddleware(object):
    def __init__(self, app):
        self.app = app
    def __call__(self, environ, start_response):
        environ['SCRIPT_NAME'] = '/yourapp'
        return self.app(environ, start_response)

app.wsgi_app = WebFactionMiddleware(app.wsgi_app)
You can put this snippet in the application's __init__.py.

Happy Flasking!
"""



# Path: app.py



# Path: deployment/webfaction.py
import os
import sys
from flask import request, Response
from app import app

Modify your webapps/yourapp/apache2/conf/httpd.conf. At the bottom of the file add the following lines changing yourapp and yourusername according to your setup:
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>
If you have choosed / as the mout point for your application you are done. If you mounted the application somewhere else (i.e. /blog) there is some additional work to do.

You need to write a WSGI middleware that prefixes SCRIPT_NAME with that prefix otherwise the url_for function will not be able to create the correct URLs for you (the following snippets is kindly provided by Armin himself).

class WebFactionMiddleware(object):
    def __init__(self, app):
        self.app = app
    def __call__(self, environ, start_response):
        environ['SCRIPT_NAME'] = '/yourapp'
        return self.app(environ, start_response)

app.wsgi_app = WebFactionMiddleware(app.wsgi_app)
You can put this snippet in the application's __init__.py.

Happy Flasking!
"""



@app.route('/')