diff --git a/src/utils/MessageHandler.py b/src/core/MessageHandler.py similarity index 100% rename from src/utils/MessageHandler.py rename to src/core/MessageHandler.py diff --git a/src/core/__init__.py b/src/core/__init__.py new file mode 100644 index 0000000..2141f4c --- /dev/null +++ b/src/core/__init__.py @@ -0,0 +1,10 @@ +from flask import Flask +from flask_sqlalchemy import SQLAlchemy + +app = Flask(__name__) +app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///static/db/database.db" +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + +db = SQLAlchemy(app) + +from core import routes diff --git a/src/core/models.py b/src/core/models.py new file mode 100644 index 0000000..84699d1 --- /dev/null +++ b/src/core/models.py @@ -0,0 +1,11 @@ +from core import db + + +class Table(db.Model): + # title = db.Column(db.String, nullable=False) + # icon = db.Column(db.String, nullable=False) + # link = db.Column(db.String, nullable=False) + id = db.Column(db.Integer, nullable=False, primary_key=True, unique=True, autoincrement=True) + + def __repr__(self): + return f"['{self.title}', '{self.icon}', '{self.link}', '{self.id}']" diff --git a/src/app.py b/src/core/routes.py similarity index 68% rename from src/app.py rename to src/core/routes.py index b021672..749f295 100644 --- a/src/app.py +++ b/src/core/routes.py @@ -1,13 +1,14 @@ +from flask import request, render_template +from core import app, db # Get from __init__ + +from core.models import Table # Get db models +from core.MessageHandler import MessageHandler # Get simple message processor + + # Python imports -from flask import Flask, request, render_template - -# Application imports -from utils import DBConnect, MessageHandler -app = Flask(__name__) msgHandler = MessageHandler() -db = DBConnect() @app.route('/', methods=['GET', 'POST']) diff --git a/src/static/css/bootstrap/bootstrap-datepicker.css b/src/core/static/css/bootstrap/bootstrap-datepicker.css similarity index 100% rename from src/static/css/bootstrap/bootstrap-datepicker.css rename to src/core/static/css/bootstrap/bootstrap-datepicker.css diff --git a/src/static/css/bootstrap/bootstrap.min.css b/src/core/static/css/bootstrap/bootstrap.min.css similarity index 100% rename from src/static/css/bootstrap/bootstrap.min.css rename to src/core/static/css/bootstrap/bootstrap.min.css diff --git a/src/static/css/main.css b/src/core/static/css/main.css similarity index 100% rename from src/static/css/main.css rename to src/core/static/css/main.css diff --git a/src/static/db/database.db b/src/core/static/db/database.db similarity index 100% rename from src/static/db/database.db rename to src/core/static/db/database.db diff --git a/src/static/faveicon.png b/src/core/static/faveicon.png similarity index 100% rename from src/static/faveicon.png rename to src/core/static/faveicon.png diff --git a/src/static/imgs/placeholder.png b/src/core/static/imgs/placeholder.png similarity index 100% rename from src/static/imgs/placeholder.png rename to src/core/static/imgs/placeholder.png diff --git a/src/static/js/bootstrap/bootstrap-datepicker.min.js b/src/core/static/js/bootstrap/bootstrap-datepicker.min.js similarity index 100% rename from src/static/js/bootstrap/bootstrap-datepicker.min.js rename to src/core/static/js/bootstrap/bootstrap-datepicker.min.js diff --git a/src/static/js/bootstrap/bootstrap.min.js b/src/core/static/js/bootstrap/bootstrap.min.js similarity index 100% rename from src/static/js/bootstrap/bootstrap.min.js rename to src/core/static/js/bootstrap/bootstrap.min.js diff --git a/src/static/js/bootstrap/jquery-3.3.1.slim.min.js b/src/core/static/js/bootstrap/jquery-3.3.1.slim.min.js similarity index 100% rename from src/static/js/bootstrap/jquery-3.3.1.slim.min.js rename to src/core/static/js/bootstrap/jquery-3.3.1.slim.min.js diff --git a/src/static/js/bootstrap/moment.min.js b/src/core/static/js/bootstrap/moment.min.js similarity index 100% rename from src/static/js/bootstrap/moment.min.js rename to src/core/static/js/bootstrap/moment.min.js diff --git a/src/static/js/bootstrap/popper.min.js b/src/core/static/js/bootstrap/popper.min.js similarity index 100% rename from src/static/js/bootstrap/popper.min.js rename to src/core/static/js/bootstrap/popper.min.js diff --git a/src/templates/error.html b/src/core/templates/error.html similarity index 100% rename from src/templates/error.html rename to src/core/templates/error.html diff --git a/src/templates/index.html b/src/core/templates/index.html similarity index 100% rename from src/templates/index.html rename to src/core/templates/index.html diff --git a/src/templates/layout.html b/src/core/templates/layout.html similarity index 100% rename from src/templates/layout.html rename to src/core/templates/layout.html diff --git a/src/start.sh b/src/start.sh index 50ab067..7ca40d8 100755 --- a/src/start.sh +++ b/src/start.sh @@ -8,6 +8,6 @@ function main() { source "../bin/activate" # Note can replace 127.0.0.1 with 0.0.0.0 to make it 'network/internet' accessable... - gunicorn app:app -b 127.0.0.1:8080 # : IE : } +gunicorn wsgi:app -b 127.0.0.1:4040 # : IE : main $@; diff --git a/src/utils/DBConnect.py b/src/utils/DBConnect.py deleted file mode 100644 index d10a555..0000000 --- a/src/utils/DBConnect.py +++ /dev/null @@ -1,53 +0,0 @@ -import os, sqlite3 - -class DBConnect: - def __init__(self): - try: - self.db = None - self.conn = None - print("DBConnect initialized...") - except Exception as e: - print("Exception raised:") - print(e) - raise - - def createConnection(self): - self.db = sqlite3.connect('static/db/database.db') - self.conn = self.db.cursor() - - def closeConnection(self): - self.conn.close() - - - def createEntry(self, args): - try: - # Example Insert - # sql = "INSERT INTO bills (Title, Amount, MoYr, Duedate, Optional) Values(?,?,?,?,?)"; - # ps = (TITLE, float(AMOUNT), MOYR, DATE, OPTIONAL, ) - self.conn.execute(sql, ps) - self.db.commit() - except Exception as e: - print("Exception raised:") - print(e) - - def updateEntry(self, args): - try: - # Example Update - # sql = "UPDATE bills SET Title = ?, Amount = ?, MoYr = ?, Duedate = ?, Optional = ? WHERE id = ?"; - # ps = (TITLE, float(AMOUNT), MOYR, DATE, OPTIONAL, int(ID), ) - self.conn.execute(sql, ps) - self.db.commit() - except Exception as e: - print("Exception raised:") - print(e) - - def deleteEntry(self, ID): - try: - # Example Delete - # sql = "DELETE FROM bills WHERE id = ?"; - # ps = (int(ID), ) - self.conn.execute(sql, ps) - self.db.commit() - except Exception as e: - print("Exception raised:") - print(e) diff --git a/src/utils/__init__.py b/src/utils/__init__.py deleted file mode 100644 index 109601e..0000000 --- a/src/utils/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from utils.DBConnect import DBConnect -from utils.MessageHandler import MessageHandler diff --git a/src/wsgi.py b/src/wsgi.py new file mode 100644 index 0000000..03ea9cb --- /dev/null +++ b/src/wsgi.py @@ -0,0 +1,4 @@ +from core import app + +if __name__ == '__main__': + app.run(debug=True)