Spaces:
Sleeping
Sleeping
Download src/api/views.py from Darshankumarr03/vibesense: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/spaces/Darshankumarr03/vibesense/resolve/main/src/api/views.py
- Command line
-
hf download hf://spaces/Darshankumarr03/vibesense/src/api/views.py
-
curl -L -o views.py https://huggingface.co/spaces/Darshankumarr03/vibesense/resolve/main/src/api/views.py
1.67 kB
| from flask import Blueprint, render_template, session, redirect, current_app | |
| from src.services import supabase_service | |
| from src.core.constants import RELAXATION_DATA | |
| views_bp = Blueprint('views', __name__) | |
| def index(): | |
| return render_template('index.html') | |
| def analyze(): | |
| if not session.get('user'): | |
| return redirect('/login') | |
| return render_template('analyze.html') | |
| def music(): | |
| return render_template('music.html') | |
| def relaxation(): | |
| return render_template('relaxation.html') | |
| def about(): | |
| return render_template('about.html') | |
| def contact(): | |
| return render_template('contact.html') | |
| def login(): | |
| return render_template('login.html') | |
| def register(): | |
| return render_template('register.html') | |
| def admin_panel(): | |
| user = session.get('user') | |
| if not user or user.get('role') != 'admin': | |
| return redirect('/login') | |
| return render_template('admin.html') | |
| def get_relaxation_tips(): | |
| user = session.get('user') | |
| last_emotion = session.get('last_emotion', 'Neutral') | |
| if user: | |
| db_emotion = supabase_service.get_latest_emotion(user.get('id')) | |
| if db_emotion: last_emotion = db_emotion | |
| data = RELAXATION_DATA.get(last_emotion, RELAXATION_DATA['Neutral']) | |
| return { | |
| 'emotion': last_emotion, | |
| 'tips': data['tips'], | |
| 'affirmation': data['affirmation'] | |
| } | |