diff --git a/Vagrantfile b/Vagrantfile index c3fd6bf..ca7721a 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/8878 +class VagrantPlugins::ProviderVirtualBox::Action::Network + def dhcp_server_matches_config?(dhcp_server, config) + true + end +end 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/flask_init.py b/edison/app.py similarity index 65% rename from flask_init.py rename to edison/app.py index 14ad216..11d4c69 100644 --- a/flask_init.py +++ b/edison/app.py @@ -1,6 +1,9 @@ -from flask import Flask, render_template +import edison -app = Flask(__name__) +from flask import render_template + + +app = edison.app @app.route("/") def index(): 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