majuna/app/portal/eotk.py

42 lines
1 KiB
Python
Raw Permalink Normal View History

from flask import Blueprint, Response, current_app, render_template
2022-05-16 11:44:03 +01:00
from flask.typing import ResponseReturnValue
from sqlalchemy import desc
2022-05-13 16:20:44 +01:00
from app.models.base import Group
from app.models.onions import Eotk
bp = Blueprint("eotk", __name__)
_SECTION_TEMPLATE_VARS = {
"section": "eotk",
2024-12-06 18:15:47 +00:00
"help_url": "https://bypass.censorship.guide/user/eotk.html",
}
@bp.route("/list")
2022-05-16 11:44:03 +01:00
def eotk_list() -> ResponseReturnValue:
2024-12-06 18:15:47 +00:00
instances = (
Eotk.query.filter(Eotk.destroyed.is_(None)).order_by(desc(Eotk.added)).all()
)
return render_template(
"list.html.j2",
title="EOTK Instances",
item="eotk",
items=instances,
**_SECTION_TEMPLATE_VARS
)
2022-05-13 16:20:44 +01:00
@bp.route("/conf/<group_id>")
2022-05-16 11:44:03 +01:00
def eotk_conf(group_id: int) -> ResponseReturnValue:
2022-05-13 16:20:44 +01:00
group = Group.query.filter(Group.id == group_id).first()
2024-12-06 18:15:47 +00:00
return Response(
render_template(
"sites.conf.j2",
bypass_token=current_app.config["BYPASS_TOKEN"],
group=group,
),
content_type="text/plain",
)