27 lines
716 B
Python
27 lines
716 B
Python
from flask import Blueprint, render_template, request, session
|
|
|
|
from . import db
|
|
|
|
|
|
bp = Blueprint("location", __name__, url_prefix="/location")
|
|
|
|
|
|
@bp.route("/", methods=["GET", "POST"])
|
|
def index():
|
|
if request.method == "POST":
|
|
location_id = request.form.get("location_id", "")
|
|
if location_id == "":
|
|
session.pop("location", None)
|
|
else:
|
|
location = db.run_query("get_location_by_id.sql", {
|
|
"location_id": location_id}
|
|
).fetchone()
|
|
session["location"] = location
|
|
|
|
|
|
locations = db.run_query("get_locations.sql").fetchall()
|
|
|
|
return render_template("location/index.html", **{
|
|
"locations": locations
|
|
})
|