I changed the structure of my flask app to utilize modules. The app works locally, but not sure why its running into a problem here. Any ideas?
pl2flask.py
#coding: utf-8
__author__ = 'bruno'
import os
if os.path.exists('.env'):
print('Importing environment from .env...')
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from flask import send_from_directory, abort
from scripts import database_setup
import os
from settings import create_app, db
app = None
try:
app = create_app(os.getenv('FLASK_CONFIG'))
app.config.from_object(os.environ['APP_SETTINGS'])
except Exception, ex:
app = create_app('default')
print('FLASK_CONFIG or APP_SETTING not found. Using default settings(development)')
@app.errorhandler(404)
def page_not_found(e):
return 'Page not found!!!', 404
@app.route('/uploads/<tipo_registro>/<id_registro>/<filename>')
def uploaded_file(tipo_registro, id_registro, filename):
if '/' in filename or '\\' in filename:
abort(404)
path = '%s/%s/' % (tipo_registro, id_registro)
final_path = os.path.join(app.config['UPLOAD_FOLDER'], path)
return send_from_directory(final_path, filename)
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
database_setup.inserir_cliente_dgr()
database_setup.inserir_usuario_dgr()
database_setup.inserir_permissoes_bd()
database_setup.inserir_grupos_usuarios()
database_setup.dar_permissoes_ao_grupo()
database_setup.inserir_usuario_grupo()
database_setup.inserir_local_raiz()
manager.run()
WSGY.py
# This file contains the WSGI configuration required to serve up your
# web application at http://<your-username>.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#
# The below has been auto-generated for your Flask project
import sys
# add your project directory to the sys.path
project_home = u'/home/brunocodeman/pl2flask'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# import flask app but need to call it "application" for WSGI to work
from pl2flask import app as application
Error Log:
2015-06-18 07:49:26,619 :/usr/lib/python2.7/threading.py:1160: RuntimeWarning: tp_compare didn't return -1 or -2 for exception
2015-06-18 07:49:26,620 : return _active[_get_ident()]
2015-06-18 07:49:26,618 :Error running WSGI application
None
2015-06-18 07:49:32,602 :Error running WSGI application
None
2015-06-18 07:49:33,086 :Error running WSGI application
None