]>
git.gir.st - subscriptionfeed.git/blob - app/example_plugin/__init__.py
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).
8 from flask
import Blueprint
9 from flask_login
import current_user
11 from ..common
.common
import *
13 frontend
= Blueprint(__name__
.rpartition('.')[2], __name__
)
15 @frontend.route('/hello/')
16 @frontend.route('/hello/<name>')
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:
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