mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 12:29:30 +02:00
tests
This commit is contained in:
31
tests/test_app.py
Normal file
31
tests/test_app.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from flask import Flask, redirect, url_for
|
||||
from flask_discord import DiscordOAuth2Session
|
||||
|
||||
OAUTH2_CLIENT_ID = 490732332240863233
|
||||
OAUTH2_CLIENT_SECRET = "GjKMenfebgLrOYQ_A_X7ouaWv9IhWdbI"
|
||||
OAUTH2_REDIRECT_URI = "http://127.0.0.1:5000/callback"
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = b"%\xe0'\x01\xdeH\x8e\x85m|\xb3\xffCN\xc9g"
|
||||
discord = DiscordOAuth2Session(OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRET, OAUTH2_REDIRECT_URI)
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
return discord.make_session()
|
||||
|
||||
|
||||
@app.route("/callback")
|
||||
def callback():
|
||||
discord.callback()
|
||||
return redirect(url_for(".me"))
|
||||
|
||||
|
||||
@app.route("/me")
|
||||
def me():
|
||||
return discord.get_json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
Reference in New Issue
Block a user