4 changed files with 45 additions and 13 deletions
@ -1,18 +1,31 @@ |
|||||||
from flask import Flask, render_template |
from flask import Flask |
||||||
|
from db import get_db_connection |
||||||
|
|
||||||
app = Flask( |
app = Flask(__name__) |
||||||
__name__, |
|
||||||
template_folder="../templates", |
|
||||||
static_folder="../static", |
|
||||||
) |
|
||||||
|
|
||||||
@app.route("/") |
@app.route("/") |
||||||
def index(): |
def index(): |
||||||
return render_template( |
return "OTB Billing v0.0.3 running" |
||||||
"base.html", |
|
||||||
page_title="OTB Billing", |
|
||||||
content="OTB Billing v0.0.1 is alive." |
|
||||||
) |
|
||||||
|
|
||||||
|
@app.route("/dbtest") |
||||||
|
def dbtest(): |
||||||
|
try: |
||||||
|
conn = get_db_connection() |
||||||
|
cursor = conn.cursor() |
||||||
|
cursor.execute("SELECT NOW()") |
||||||
|
result = cursor.fetchone() |
||||||
|
conn.close() |
||||||
|
|
||||||
|
return f""" |
||||||
|
<h1>Database Connection OK</h1> |
||||||
|
<p>Server time: {result[0]}</p> |
||||||
|
""" |
||||||
|
|
||||||
|
except Exception as e: |
||||||
|
return f""" |
||||||
|
<h1>Database Connection FAILED</h1> |
||||||
|
<pre>{e}</pre> |
||||||
|
""" |
||||||
|
|
||||||
if __name__ == "__main__": |
if __name__ == "__main__": |
||||||
app.run(host="127.0.0.1", port=5050) |
app.run(host="0.0.0.0", port=5050) |
||||||
|
|||||||
@ -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" |
||||||
Loading…
Reference in new issue