mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 04:19:31 +02:00
Somewhat better index
This commit is contained in:
@@ -16,15 +16,30 @@ app.config["DISCORD_REDIRECT_URI"] = "http://127.0.0.1:5000/callback"
|
|||||||
discord = DiscordOAuth2Session(app)
|
discord = DiscordOAuth2Session(app)
|
||||||
|
|
||||||
|
|
||||||
|
HYPERLINK = '<a href="{}">{}</a>'
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
|
if not discord.authorized:
|
||||||
|
return HYPERLINK.format(url_for(".login"), "Login")
|
||||||
|
return f"""
|
||||||
|
{HYPERLINK.format(url_for(".me"), "@ME")}<br />
|
||||||
|
{HYPERLINK.format(url_for(".logout"), "Logout")}<br />
|
||||||
|
{HYPERLINK.format(url_for(".user_guilds"), "My Servers")}<br />
|
||||||
|
{HYPERLINK.format(url_for(".add_to_guild", guild_id=475549041741135881), "Add bot to 475549041741135881.")}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/login/")
|
||||||
|
def login():
|
||||||
return discord.create_session()
|
return discord.create_session()
|
||||||
|
|
||||||
|
|
||||||
@app.route("/callback/")
|
@app.route("/callback/")
|
||||||
def callback():
|
def callback():
|
||||||
discord.callback()
|
discord.callback()
|
||||||
return redirect(url_for(".me"))
|
return redirect(url_for(".index"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/me/")
|
@app.route("/me/")
|
||||||
|
|||||||
Reference in New Issue
Block a user