diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index 51fce8c..ce24d8f --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,9 @@ __pycache__ .pytest_cache htmlcov Pipfile.lock +*.swo +*.swp +*.pyo +*.pyc +*.env +venv diff --git a/LNbits/__init__.py b/LNbits/__init__.py index 730a5a9..fb4279d 100644 --- a/LNbits/__init__.py +++ b/LNbits/__init__.py @@ -4,19 +4,17 @@ import time from flask import Flask, jsonify, render_template, request -from .db import Database, DEFAULT_PATH +from .db import Database from .helpers import encrypt +from .settings import INVOICE_KEY, ADMIN_KEY, API_ENDPOINT, DATABASE_PATH -INVOICE_KEY = "YOUR-LNTXBOT-INVOICE-KEY" # In the lntxbot bot on telegram type "/api" -ADMIN_KEY = "YOUR-LNTXBOT-ADMIN-KEY" -API_ENDPOINT = "YOUR-LNTXBOT-API-BASE-URL" - app = Flask(__name__) -def db_connect(db_path=DEFAULT_PATH): +def db_connect(db_path=DATABASE_PATH): import sqlite3 + con = sqlite3.connect(db_path) return con @@ -129,7 +127,7 @@ def lnurlwallet(): cur = con.cursor() print(thewal) cur.execute("select * from wallets WHERE user = '" + str(theid) + "'") - rows = cur.fetchall() + # rows = cur.fetchall() con.commit() cur.close() return render_template( diff --git a/LNbits/db.py b/LNbits/db.py index cb126b7..d8df20b 100644 --- a/LNbits/db.py +++ b/LNbits/db.py @@ -1,13 +1,10 @@ -import os import sqlite3 - -LNBITS_PATH = os.path.dirname(os.path.realpath(__file__)) -DEFAULT_PATH = os.path.join(LNBITS_PATH, "data", "database.sqlite3") +from .settings import DATABASE_PATH class Database: - def __init__(self, db_path: str = DEFAULT_PATH): + def __init__(self, db_path: str = DATABASE_PATH): self.path = db_path self.connection = sqlite3.connect(db_path) self.cursor = self.connection.cursor() diff --git a/LNbits/settings.py b/LNbits/settings.py new file mode 100644 index 0000000..86ad5fe --- /dev/null +++ b/LNbits/settings.py @@ -0,0 +1,8 @@ +import os + +INVOICE_KEY = os.getenv("INVOICE_KEY") +ADMIN_KEY = os.getenv("ADMIN_KEY") +API_ENDPOINT = os.getenv("API_ENDPOINT") + +LNBITS_PATH = os.path.dirname(os.path.realpath(__file__)) +DATABASE_PATH= os.getenv("DATABASE_PATH") or os.path.join(LNBITS_PATH, "data", "database.sqlite3")