Spaces:
Sleeping
Sleeping
Download routes/home.py from vioott/BookMatchAI-Python-GeminiAPI: direct link, hf CLI and curl.
- Browser
- Download file 930 Bytes
-
https://huggingface.co/spaces/vioott/BookMatchAI-Python-GeminiAPI/resolve/main/routes/home.py
- Command line
-
hf download hf://spaces/vioott/BookMatchAI-Python-GeminiAPI/routes/home.py
-
curl -L -o home.py https://huggingface.co/spaces/vioott/BookMatchAI-Python-GeminiAPI/resolve/main/routes/home.py
930 Bytes
| from flask import Blueprint, render_template, request, redirect | |
| from time import time | |
| from logs import save_log, get_all_users | |
| from constants.genres import GENRES | |
| home_bp = Blueprint('home', __name__) | |
| def inicio(): | |
| """ | |
| Rota inicial para criação de perfil ou acesso a perfis existentes. | |
| """ | |
| if request.method == 'POST': | |
| name = request.form.get('name') | |
| preferences = request.form.getlist('preferences') | |
| new_id = int(time()) | |
| initial_history = { | |
| 'name': name, | |
| 'preferences': preferences, | |
| 'chat': [] | |
| } | |
| save_log( | |
| user_id=new_id, | |
| history=initial_history, | |
| response="Perfil criado." | |
| ) | |
| return redirect(f'/chat/{new_id}') | |
| return render_template( | |
| 'start.html', | |
| profiles=get_all_users(), | |
| genres=GENRES | |
| ) | |