Skip to content

Commit

Permalink
Merge pull request #484 from NYUCCL/run_from_subfolder_heroku
Browse files Browse the repository at this point in the history
adds and option on startup to move to a different subfolder
  • Loading branch information
gureckis committed Mar 26, 2021
2 parents d81d353 + d781d4f commit 9eb49c4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions psiturk/experiment_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@ class ExperimentServer(Application):
Custom Gunicorn Server Application that serves up the Experiment application
"""

def __init__(self):
def __init__(self, app_dir=None):
"""__init__ method
Load the base config and assign some core attributes.
"""

self.loglevels = ["debug", "info", "warning", "error", "critical"]
self.load_user_config()
self.usage = None
self.callable = None
self.options = self.user_options
self.prog = None
self.do_load_config()
if app_dir:
self.cfg.set('chdir', app_dir) # get directory
self.chdir() # change to it
self.user_options = {}
print("Now serving on", "http://" + self.options["bind"])

Expand Down Expand Up @@ -106,8 +110,8 @@ def load_user_config(self):
{'timeout': config.get('Server Parameters', "server_timeout")})


def launch():
ExperimentServer().run()
def launch(app_dir=None):
ExperimentServer(app_dir).run()


if __name__ == "__main__":
Expand Down

0 comments on commit 9eb49c4

Please sign in to comment.