Somewhat better index

This commit is contained in:
thec0sm0s
2020-05-10 16:55:02 +05:30
parent ed29f41a97
commit 7cb638c60b

View File

@@ -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/")