]> git.gir.st - subscriptionfeed.git/blob - app/example_plugin/__init__.py
create video proxy endpoint
[subscriptionfeed.git] / app / example_plugin / __init__.py
1 """
2 This is an example Blueprint to base your plugin off of.
3 to use it, add the blueprint's name (e.g. "example_plugin") in
4 config/config.ini, under the [frontend] section, to the modules key (csv).
5 first-named blueprints take precidence (which allows overwriting existing
6 routes from other blueprints).
7 """
8 from flask import Blueprint
9 from flask_login import current_user
10
11 from ..common.common import *
12
13 frontend = Blueprint(__name__.rpartition('.')[2], __name__)
14
15 @frontend.route('/hello/')
16 @frontend.route('/hello/<name>')
17 def index(name=None):
18 token = getattr(current_user, 'token', 'guest') # 'standard' way to get user info when log-in is not required
19 # assume there's some other /hello/world endpoint to handle this special case:
20 if name == "world":
21 return fallback_route(name)
22 return f"hello, {name or 'you'} from user {token}!" # note: token is usually not a username, but a random string
Imprint / Impressum