Clean up for Initial Deployment
This commit is contained in:
37
app.py
37
app.py
@@ -121,6 +121,11 @@ def render_main():
|
||||
)
|
||||
|
||||
|
||||
@app.route("/help")
|
||||
def help():
|
||||
return render_template("help.html")
|
||||
|
||||
|
||||
@app.post("/login")
|
||||
def login():
|
||||
username = request.form.get("username")
|
||||
@@ -142,6 +147,12 @@ def login():
|
||||
return redirect(url_for(session.get("main", "index_ade")))
|
||||
|
||||
|
||||
@app.route("/logout")
|
||||
def logout():
|
||||
session["username"] = None
|
||||
return redirect(url_for("index_ade"))
|
||||
|
||||
|
||||
@app.route("/register", methods=["GET", "POST"])
|
||||
def register():
|
||||
if request.method == "POST":
|
||||
@@ -202,10 +213,11 @@ def register():
|
||||
|
||||
@app.route("/search")
|
||||
def search():
|
||||
stype = request.args.get("search-type")
|
||||
query = request.args.get("search")
|
||||
print(stype, query)
|
||||
return redirect(url_for("index"))
|
||||
abort(500)
|
||||
# stype = request.args.get("search-type")
|
||||
# query = request.args.get("search")
|
||||
# print(stype, query)
|
||||
# return redirect(url_for("index"))
|
||||
|
||||
|
||||
@app.route("/database", methods=["GET", "POST"])
|
||||
@@ -224,7 +236,8 @@ def database():
|
||||
query = json.loads(query)
|
||||
except:
|
||||
abort(400)
|
||||
results = db[collection].find(query, {"_id": 1, "id": 1})
|
||||
results = list(db[collection].find(query, {"_id": 1, "id": 1}))
|
||||
results.append({"_id": "new", "id": "new"})
|
||||
return render_template(
|
||||
"database.html", cnames=cnames, collection=collection, results=results
|
||||
)
|
||||
@@ -240,7 +253,9 @@ def database_edit(collection, oid):
|
||||
if document and "_id" in document:
|
||||
del document["_id"]
|
||||
try:
|
||||
if not document:
|
||||
if oid == "new":
|
||||
db[collection].insert_one(document)
|
||||
elif not document:
|
||||
db[collection].delete_one({"_id": ObjectId(oid)})
|
||||
elif oid:
|
||||
db[collection].replace_one({"_id": ObjectId(oid)}, document)
|
||||
@@ -249,9 +264,13 @@ def database_edit(collection, oid):
|
||||
except:
|
||||
abort(500)
|
||||
return redirect(url_for("database"))
|
||||
result = db[collection].find_one_or_404({"_id": ObjectId(oid)})
|
||||
name = result["id"]
|
||||
document = bson.dumps(result, indent=4)
|
||||
if oid == "new":
|
||||
name = "New Document"
|
||||
document = "{}"
|
||||
else:
|
||||
result = db[collection].find_one_or_404({"_id": ObjectId(oid)})
|
||||
name = result["id"]
|
||||
document = bson.dumps(result, indent=4)
|
||||
return render_template(
|
||||
"database_edit.html",
|
||||
collection=collection,
|
||||
|
||||
Reference in New Issue
Block a user