Skip to content

Commit

Permalink
Fixed loading local files twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinke Hoekstra committed Mar 2, 2017
1 parent 9d63c98 commit a122357
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
17 changes: 12 additions & 5 deletions src/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from flask import Flask
from flask_bootstrap import Bootstrap
import client
import config
import os
import config, client

from datetime import datetime
print "init", datetime.now().isoformat()

class ReverseProxied(object):
'''Wrap the application in this middleware and configure the
Expand Down Expand Up @@ -51,7 +54,11 @@ def __call__(self, environ, start_response):
if (hasattr(config, 'DEBUG')):
app.debug = config.DEBUG

# Initialize the client
client.init()

import views

if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true":
# The app is not in debug mode or we are in the reloaded process
client.init()

def run():
app.run(host="0.0.0.0", port=(config.PORT if hasattr(config, 'PORT') else 5000))
6 changes: 6 additions & 0 deletions src/app/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
import glob
import re
rdfextras.registerplugins()
import rdflib
from rdflib import Dataset, URIRef, RDFS

# from app import app

from datetime import datetime
print "client", datetime.now().isoformat()

# log = app.logger
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)

Expand Down
3 changes: 2 additions & 1 deletion src/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from rdflib import URIRef, Literal, BNode

from app import app

from datetime import datetime
print "views", datetime.now().isoformat()

log = app.logger
log.setLevel(logging.DEBUG)
Expand Down
8 changes: 6 additions & 2 deletions src/run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from app import app, config
from app import run

from datetime import datetime
print "run", datetime.now().isoformat()

if __name__ == "__main__":
app.run(host="0.0.0.0", port=(config.PORT if hasattr(config, 'PORT') else 5000))
run()

0 comments on commit a122357

Please sign in to comment.