Skip to content

Commit

Permalink
Fixed problems with usage of GUnicorn and other WSGI servers
Browse files Browse the repository at this point in the history
  • Loading branch information
lkiesow committed Nov 20, 2013
1 parent 2448586 commit 06eb3cf
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
app = Flask(__name__)
app.config.from_pyfile('config.py')

app.jinja_loader = FileSystemLoader('%s/templates/%s/' % (
os.path.dirname(os.path.abspath(__file__)),
app.config['TEMPLATE']))
app.static_folder = 'static/%s/' % app.config['TEMPLATE']

# Try to import a memcached library
try:
import pylibmc
Expand All @@ -44,6 +39,26 @@
raise ImportError("Neither a module 'pylibmc' nor 'memcache'")


@app.before_first_request
def init():
# import player plugin
global player
player = []
load_player_plugin( app.config['PLAYER_PLUGINS'] )

# import player plugin
global seriescolor
seriescolor = None
load_seriescolor_plugin( app.config['SERIESCOLOR_PLUGIN'] )

# set template
app.jinja_loader = FileSystemLoader('%s/templates/%s/' % (
os.path.dirname(os.path.abspath(__file__)),
app.config['TEMPLATE']))
app.static_folder = 'static/%s/' % app.config['TEMPLATE']



def load_player_plugin(names):
for n in names:
mod = __import__('plugin.player.%s' % n)
Expand Down Expand Up @@ -429,18 +444,7 @@ def logout():
response.headers['Set-Cookie'] = 'JSESSIONID=x; Expires=Wed, 09 Jun 1980 10:18:14 GMT'
return response


if __name__ == '__main__':

# import player plugin
player = []
load_player_plugin( app.config['PLAYER_PLUGINS'] )

# import player plugin
seriescolor = None
load_seriescolor_plugin( app.config['SERIESCOLOR_PLUGIN'] )
print seriescolor

app.run(
host=(app.config.get('SERVER_HOST') or 'localhost'),
port=(app.config.get('SERVER_PORT') or 5000),
Expand Down

0 comments on commit 06eb3cf

Please sign in to comment.