I currently have an app that uses flask like so:
app.add_url_rule('/', view_func=dashboard.render)
app.add_url_rule('/callback', view_func=bot.callback, methods=['POST'])
Basically, dashboard.render
will display a webpage while bot.callback
is a special url for a bot that I made.
If a user access /
then then it would trigger dashboard.render
, while if he/she accesses /callback
with a POST
method, then it would trigger bot.callback
. However, try to access any other site, for example /123
or /asd
then it would trigger a 404 Not Found
.
Is there any way to let users that access unavailable urls (in my case, other than /
and /callback
) to trigger dashboard.render
? Also, as /callback
is only available through POST
, can I also redirect 405 Method not allowed
errors to just display a webpage using dashboard.render
?
Oh and if perhaps this is insecure or not a good thing to do, please let me know.
Thank you.