Spaces:
Runtime error
Runtime error
Soham Maity commited on
Commit ·
b179349
1
Parent(s): 86593e3
feat: enhance profile route with user upload statistics and remove flash message on logout
Browse files1234567891011121318 unmodified lines32333435363738394041422 unmodified lines4546474849from flask import Blueprint, flash, redirect, render_template, url_forfrom flask_login import current_user, login_required, logout_userfrom flask_dance.contrib.discord import discordfrom flask_dance.contrib.google import googlemain_bp = Blueprint("main", __name__)@main_bp.route("/")@login_requireddef index():return render_template("index.html")18 unmodified linesgoogle_profile = _safe_json(google, "/oauth2/v2/userinfo")discord_profile = _safe_json(discord, "/api/users/@me")return render_template("profile.html",user=current_user,google_profile=google_profile,discord_profile=discord_profile,)2 unmodified linesdef logout():logout_user()flash("Signed out successfully.", "info")return redirect(url_for("main.login"))123456789101112131418 unmodified lines333435363738394041424344454647484950515253542 unmodified lines57585960from flask import Blueprint, redirect, render_template, url_forfrom flask_login import current_user, login_required, logout_userfrom flask_dance.contrib.discord import discordfrom flask_dance.contrib.google import googlefrom app.models import Notemain_bp = Blueprint("main", __name__)@main_bp.route("/")def index():return render_template("index.html")18 unmodified linesgoogle_profile = _safe_json(google, "/oauth2/v2/userinfo")discord_profile = _safe_json(discord, "/api/users/@me")# Get user statstotal_uploads = Note.query.filter_by(user_id=current_user.id).count()recent_uploads = (Note.query.filter_by(user_id=current_user.id).order_by(Note.created_at.desc()).limit(5).all())return render_template("profile.html",user=current_user,google_profile=google_profile,discord_profile=discord_profile,total_uploads=total_uploads,recent_uploads=recent_uploads,)2 unmodified linesdef logout():logout_user()return redirect(url_for("main.login"))
app/blueprints/main.py+14-3