lnbits-legend/lnbits/extensions/example/views.py

27 lines
771 B
Python
Raw Normal View History

2020-02-19 23:14:53 +00:00
#add your dependencies here
2020-02-19 23:16:06 +00:00
2020-02-19 23:14:53 +00:00
from flask import jsonify, render_template, request, redirect, url_for
from lnbits.db import open_db, open_ext_db
2020-02-19 23:15:50 +00:00
from lnbits.extensions.example import example_ext
2020-02-19 23:14:53 +00:00
#add your endpoints here
@example_ext.route("/")
def index():
"""Try to add descriptions for others."""
2020-02-23 00:46:38 +00:00
usr = request.args.get("usr")
if usr:
if not len(usr) > 20:
return redirect(url_for("home"))
# Get all the data
with open_db() as db:
user_wallets = db.fetchall("SELECT * FROM wallets WHERE user = ?", (usr,))
user_ext = db.fetchall("SELECT extension FROM extensions WHERE user = ? AND active = 1", (usr,))
user_ext = [v[0] for v in user_ext]
2020-02-19 23:14:53 +00:00
return render_template(
"example/index.html"
)