From a156d9220846be749cb6051686ccad73994a0efd Mon Sep 17 00:00:00 2001 From: dortal94 Date: Sat, 25 Apr 2020 18:57:23 +0100 Subject: [PATCH 1/5] Restructured project - Renamed test folder to tests. - Renamed flask_init file to app and updated its name inside setup.sh. - Moved static and templates folders to edison folder. --- flask_init.py => edison/app.py | 0 {static => edison/static}/hello-world-image.png | Bin {templates => edison/templates}/index.html | 0 setup.sh | 8 +++++--- {test => tests}/init_test.py | 0 5 files changed, 5 insertions(+), 3 deletions(-) rename flask_init.py => edison/app.py (100%) rename {static => edison/static}/hello-world-image.png (100%) rename {templates => edison/templates}/index.html (100%) rename {test => tests}/init_test.py (100%) diff --git a/flask_init.py b/edison/app.py similarity index 100% rename from flask_init.py rename to edison/app.py diff --git a/static/hello-world-image.png b/edison/static/hello-world-image.png similarity index 100% rename from static/hello-world-image.png rename to edison/static/hello-world-image.png diff --git a/templates/index.html b/edison/templates/index.html similarity index 100% rename from templates/index.html rename to edison/templates/index.html diff --git a/setup.sh b/setup.sh index e344782..02dcd7a 100644 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,7 @@ #!/bin/bash +FLASK_PORT=5000 + echo "updating apt before installation" sudo apt-get update @@ -15,6 +17,6 @@ sudo apt-get install -y postgresql postgresql-contrib echo "install requirements" pip3 install -r /vagrant/requirements.txt -echo "running flask_init.py" -export FLASK_APP=/vagrant/flask_init.py -python3 -m flask run --host=0.0.0.0 >> /vagrant/log.log 2>&1 & +echo "running app.py" +export FLASK_APP=/vagrant/edison/app.py +flask run -h 0.0.0.0 -p $FLASK_PORT >> /vagrant/edison/app.log 2>&1 & diff --git a/test/init_test.py b/tests/init_test.py similarity index 100% rename from test/init_test.py rename to tests/init_test.py From 4e7656ff3306ad35529ec01e07d18cce54137389 Mon Sep 17 00:00:00 2001 From: dortal94 Date: Sat, 25 Apr 2020 18:58:29 +0100 Subject: [PATCH 2/5] Updated Vagrantfile - Changed network definition to private. - Added a dhcp bug fix. --- Vagrantfile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index c3fd6bf..61a4b3c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,11 +1,8 @@ -FLASK_PORT=5000 -POSTGRESQL_PORT=5432 - Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/bionic64" config.vm.provision :shell, path: "setup.sh" - config.vm.network :forwarded_port, guest: FLASK_PORT, host: FLASK_PORT - config.vm.network :forwarded_port, guest: POSTGRESQL_PORT, host: POSTGRESQL_PORT + config.vm.network "private_network", type: "dhcp" config.vm.provider "virtualbox" do |v| v.gui = false v.name = "Edison_test" @@ -14,3 +11,11 @@ Vagrant.configure("2") do |config| end end + +# Fixes a dhcp configuration conflict of the private network. +# Issue: https://github.com/hashicorp/vagrant/issues/3083 +class VagrantPlugins::ProviderVirtualBox::Action::Network + def dhcp_server_matches_config?(dhcp_server, config) + true + end +end From 33b715cbe967fc880857840ff5b74aafd99352d7 Mon Sep 17 00:00:00 2001 From: dortal94 Date: Sat, 25 Apr 2020 19:02:20 +0100 Subject: [PATCH 3/5] Made edison folder a module Added init file to edison folder to make it a module. --- edison/__init__.py | 8 ++++++++ edison/app.py | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 edison/__init__.py diff --git a/edison/__init__.py b/edison/__init__.py new file mode 100644 index 0000000..dac6ddb --- /dev/null +++ b/edison/__init__.py @@ -0,0 +1,8 @@ +import os + +from flask import Flask + + +# Put app here so the entire app could import it. +app = Flask(__name__) +basedir = os.path.abspath(os.path.dirname(__file__)) diff --git a/edison/app.py b/edison/app.py index 14ad216..6ef3f3e 100644 --- a/edison/app.py +++ b/edison/app.py @@ -1,6 +1,11 @@ -from flask import Flask, render_template +import edison -app = Flask(__name__) +from flask import render_template + + +# API description in swagger - https://app.swaggerhub.com/apis/DoRTaL94/UserManagment/1.0.0 + +app = edison.app @app.route("/") def index(): From dc33484b3533020d18428dc4e9234c507308ba38 Mon Sep 17 00:00:00 2001 From: dortal94 Date: Sun, 26 Apr 2020 11:19:16 +0100 Subject: [PATCH 4/5] Removed unnecessary comment --- edison/app.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/edison/app.py b/edison/app.py index 6ef3f3e..11d4c69 100644 --- a/edison/app.py +++ b/edison/app.py @@ -3,8 +3,6 @@ from flask import render_template -# API description in swagger - https://app.swaggerhub.com/apis/DoRTaL94/UserManagment/1.0.0 - app = edison.app @app.route("/") From 64ec2e4df516070345e6cff78a69d362886c4e5c Mon Sep 17 00:00:00 2001 From: dortal94 Date: Sat, 2 May 2020 11:44:18 +0100 Subject: [PATCH 5/5] Changed comment in Vagrantfile Changed the linked issue to a more relevant one --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 61a4b3c..ca7721a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,7 +13,7 @@ Vagrant.configure("2") do |config| end # Fixes a dhcp configuration conflict of the private network. -# Issue: https://github.com/hashicorp/vagrant/issues/3083 +# Issue: https://github.com/hashicorp/vagrant/issues/8878 class VagrantPlugins::ProviderVirtualBox::Action::Network def dhcp_server_matches_config?(dhcp_server, config) true