Skip to content

Instantly share code, notes, and snippets.

@qtqgyt
Created December 5, 2023 04:41
Show Gist options
  • Save qtqgyt/fce8cd04dc6f42893e1b0cedb1911ac6 to your computer and use it in GitHub Desktop.
Save qtqgyt/fce8cd04dc6f42893e1b0cedb1911ac6 to your computer and use it in GitHub Desktop.
from flask import Flask, request, render_template
import subprocess
app = Flask(__name__, static_folder='web', template_folder='../web/templates')
@app.route("/discord/auth/callback")
def handle_auth_callback():
# Extract the code parameter from the query parameters
code = request.args.get("code")
# Check if the code parameter is provided
if not code:
return "No code parameter provided", 400
# Append the code to the code_list
code_list = [code] # Create an empty list if no previous code exists
# Pass the code to the separate script using subprocess
subprocess.Popen(["python", "get_token.py"] + code_list)
# Render the success template
return render_template('index.html')
from flask import send_from_directory
@app.route('/discord/auth/nicepage.css')
def serve_nicepage_css():
return send_from_directory('templates', 'nicepage.css')
if __name__ == "__main__":
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment