f43b13f625
- Created `__init__.py` for blueprint registration. - Implemented `auth.py` for user authentication (login, register, logout). - Added `admin.py` for admin functionalities (user management, stats). - Developed `dashboard.py` for user dashboard displaying user info and generated content. - Created `gallery.py` for managing and displaying images and videos. - Implemented `generate.py` for text, image, and video generation functionalities. - Added `profile.py` for user profile management. - Updated templates to reflect new route structures and improve navigation.
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
"""Dashboard blueprint."""
|
|
from flask import Blueprint, render_template, session
|
|
|
|
from ..helpers import _api, login_required
|
|
|
|
dashboard_bp = Blueprint("dashboard", __name__)
|
|
|
|
|
|
@dashboard_bp.get("/dashboard")
|
|
@login_required
|
|
def index():
|
|
token = session["access_token"]
|
|
resp = _api("GET", "/users/me", token=token)
|
|
user = resp.json() if resp.status_code == 200 else {}
|
|
img_resp = _api("GET", "/images/", token=token)
|
|
images = img_resp.json() if img_resp.status_code == 200 else []
|
|
gen_resp = _api("GET", "/generate/images", token=token)
|
|
generated_images = gen_resp.json() if gen_resp.status_code == 200 else []
|
|
|
|
vid_resp = _api("GET", "/generate/videos", token=token)
|
|
videos = vid_resp.json() if vid_resp.status_code == 200 else []
|
|
pending_videos = [v for v in videos if v.get(
|
|
"status") not in ("completed", "failed")]
|
|
completed_videos = [v for v in videos if v.get("status") == "completed"]
|
|
|
|
return render_template("dashboard.html", user=user, images=images,
|
|
generated_images=generated_images,
|
|
pending_videos=pending_videos,
|
|
completed_videos=completed_videos) |