From bb4d1061305309171e369b5722a7311811ca7180 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Wed, 16 Mar 2016 20:41:05 -0500 Subject: [PATCH] Fix deploying with gunicorn. --- Vagrantfile | 4 ++++ deploy | 0 scripts/requirements.txt | 2 +- scripts/setup.sh | 0 server/api/__init__.py | 1 - server/app.py | 13 +++++++++---- web/includes/meta.html | 0 7 files changed, 14 insertions(+), 6 deletions(-) mode change 100755 => 100644 deploy mode change 100755 => 100644 scripts/setup.sh mode change 100755 => 100644 web/includes/meta.html diff --git a/Vagrantfile b/Vagrantfile index 6a97d6a..5d5c108 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -19,4 +19,8 @@ Vagrant.configure(2) do |config| config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] end + config.vm.provider :virtualbox do |vb| + vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] + end end diff --git a/deploy b/deploy old mode 100755 new mode 100644 diff --git a/scripts/requirements.txt b/scripts/requirements.txt index 884662d..103f3bf 100644 --- a/scripts/requirements.txt +++ b/scripts/requirements.txt @@ -5,5 +5,5 @@ SQLAlchemy gunicorn requests voluptuous -PIL +Pillow markdown2 \ No newline at end of file diff --git a/scripts/setup.sh b/scripts/setup.sh old mode 100755 new mode 100644 diff --git a/server/api/__init__.py b/server/api/__init__.py index a477503..4c362a8 100644 --- a/server/api/__init__.py +++ b/server/api/__init__.py @@ -5,5 +5,4 @@ import problem import user import stats import team -import tools import utils diff --git a/server/app.py b/server/app.py index 1f10876..ec403b2 100644 --- a/server/app.py +++ b/server/app.py @@ -18,6 +18,8 @@ app.config.from_object(config) if not os.path.exists(app.config["UPLOAD_FOLDER"]): os.makedirs(app.config["UPLOAD_FOLDER"]) +if not os.path.exists("pfp"): + os.makedirs("pfp") with app.app_context(): from api.models import db, Files, Teams, Problems, Solves, Users @@ -44,10 +46,12 @@ def api_main(): def page_not_found(e): return send_file("../web/index.html") -def run(args): +def run(args=None): with app.app_context(): - keyword_args = dict(args._get_kwargs()) - app.debug = keyword_args["debug"] if "debug" in keyword_args else False + try: + keyword_args = dict(args._get_kwargs()) + app.debug = keyword_args["debug"] if "debug" in keyword_args else False + except: pass app.run(host="0.0.0.0", port=8000) def load_problems(args): @@ -112,4 +116,5 @@ def main(): else: parser.print_help() -main() \ No newline at end of file +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/web/includes/meta.html b/web/includes/meta.html old mode 100755 new mode 100644