diff --git a/VERSION b/VERSION index 4e379d2..bcab45a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.2 +0.0.3 diff --git a/backend/app.py b/backend/app.py index 46d049f..c168620 100644 --- a/backend/app.py +++ b/backend/app.py @@ -1,18 +1,31 @@ -from flask import Flask, render_template +from flask import Flask +from db import get_db_connection -app = Flask( - __name__, - template_folder="../templates", - static_folder="../static", -) +app = Flask(__name__) @app.route("/") def index(): - return render_template( - "base.html", - page_title="OTB Billing", - content="OTB Billing v0.0.1 is alive." - ) + return "OTB Billing v0.0.3 running" +@app.route("/dbtest") +def dbtest(): + try: + conn = get_db_connection() + cursor = conn.cursor() + cursor.execute("SELECT NOW()") + result = cursor.fetchone() + conn.close() + + return f""" +
Server time: {result[0]}
+ """ + + except Exception as e: + return f""" +{e}
+ """
+
if __name__ == "__main__":
- app.run(host="127.0.0.1", port=5050)
+ app.run(host="0.0.0.0", port=5050)
diff --git a/backend/config.py b/backend/config.py
new file mode 100644
index 0000000..c6ff6ac
--- /dev/null
+++ b/backend/config.py
@@ -0,0 +1,8 @@
+import os
+
+class Config:
+ DB_HOST = "127.0.0.1"
+ DB_PORT = 3306
+ DB_NAME = "otb_billing"
+ DB_USER = "otb_billing"
+ DB_PASSWORD = "!2Eas678"
diff --git a/backend/db.py b/backend/db.py
new file mode 100644
index 0000000..a10f72b
--- /dev/null
+++ b/backend/db.py
@@ -0,0 +1,11 @@
+import mysql.connector
+from config import Config
+
+def get_db_connection():
+ return mysql.connector.connect(
+ host=Config.DB_HOST,
+ port=Config.DB_PORT,
+ user=Config.DB_USER,
+ password=Config.DB_PASSWORD,
+ database=Config.DB_NAME
+ )