✨ add dynamic link
This commit is contained in:
parent
dadc514e7c
commit
b5b52205c4
1 changed files with 15 additions and 0 deletions
15
src/fn.py
15
src/fn.py
|
@ -1,5 +1,20 @@
|
|||
import flask
|
||||
from htmlpy import Link
|
||||
|
||||
|
||||
def is_onion(req: flask.globals.request) -> bool:
|
||||
return req.host.endswith("onion")
|
||||
|
||||
|
||||
def is_i2p(req: flask.globals.request) -> bool:
|
||||
return req.host.endswith("i2p")
|
||||
|
||||
|
||||
def dynamic_link(
|
||||
inner, normal: str, onion: str, i2p: str, req: flask.globals.request
|
||||
) -> Link:
|
||||
if is_onion(req):
|
||||
return Link(onion, inner)
|
||||
if is_i2p(req):
|
||||
return Link(i2p, inner)
|
||||
return Link(normal, inner)
|
||||
|
|
Loading…
Add table
Reference in a new issue