I am trying to create simple mod_wsgi application with following structure.
Files:
- /var/www/test/application.wsgi - mod_wsgi process
- /var/www/test/hello.py - python application
- /var/www/test/static/index.html - static content
- /etc/apache2/sites-available/test.conf - application configuration
application.wsgi
import sys
activate_this = '/home/ubuntu/environments/test/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
sys.path.insert(0, '/var/www/test')
from hello import app as application
hello.py
from flask import Flask
app = Flask(__name__, static_url_path='')
@app.route("/")
def root():
return app.send_static_file('index.html')
index.html
<html><h1>testing</h1></html>
test.conf
<VirtualHost *:80>
ServerName localhost
WSGIDaemonProcess hello user=ubuntu group=ubuntu threads=5
WSGIScriptAlias / /var/www/test/application.wsgi
WSGIScriptReloading On
<Directory /var/www/test>
WSGIProcessGroup hello
WSGIApplicationGroup %{GLOBAL}
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog /var/log/test/error.log
LogLevel warn
CustomLog /var/log/test/access.log combined
ServerSignature Off
</VirtualHost>
The above application works perfectly fine and it displays static content from index.html.
As soon as I introduce Blueprints, the application stops working
Now, the modified files are as follows:
hello.py
from flask import Flask
app = Flask(__name__, static_url_path='')
@app.route("/")
def root():
return app.send_static_file('index.html')
from views.authentication import authentication
app.register_blueprint(authentication, url_prefix='/test/auth')
/var/www/test/views/authentication.py - facebook authentication
from flask import Blueprint
authentication = Blueprint('authentication', __name__)
@authentication.route('/facebook/', method=['POST'])
def facebook():
''' facebook login '''
access_token_url = app.config.get('FACEBOOK_ACCESS_TOKEN_URL')
graph_api_url = app.config.get('FACEBOOK_GRAPH_API_URL')
pass
As soon as I introduce above Blueprint code, I start receiving 404 error (even with empty method body). Any idea, what could be the reason? I would appreciate any help or pointers.