Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba María Álvarez
/
gemini-recipe-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2924302b
authored
Aug 16, 2025
by
Alba María Álvarez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat(app.py): eliminados prints y añadida configuración de la API Key
parent
08904e1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
app.py
app.py
View file @
2924302b
import
re
,
json
,
uuid
import
re
,
os
,
json
,
uuid
from
flask
import
Flask
,
request
,
jsonify
from
flask
import
Flask
,
request
,
jsonify
from
dotenv
import
load_dotenv
from
dotenv
import
load_dotenv
import
google.generativeai
as
genai
import
google.generativeai
as
genai
...
@@ -6,6 +6,9 @@ import google.generativeai as genai
...
@@ -6,6 +6,9 @@ import google.generativeai as genai
# Cargar variables de entorno
# Cargar variables de entorno
load_dotenv
()
load_dotenv
()
# Configurar API KEY
genai
.
configure
(
api_key
=
os
.
getenv
(
"GEMINI_API_KEY"
))
# Modelo generativo
# Modelo generativo
model
=
genai
.
GenerativeModel
(
'gemini-1.5-flash'
)
model
=
genai
.
GenerativeModel
(
'gemini-1.5-flash'
)
...
@@ -97,9 +100,7 @@ def search_more_recipes():
...
@@ -97,9 +100,7 @@ def search_more_recipes():
if
auth_header
and
auth_header
.
startswith
(
"Bearer "
):
if
auth_header
and
auth_header
.
startswith
(
"Bearer "
):
token
=
auth_header
[
len
(
"Bearer "
):]
token
=
auth_header
[
len
(
"Bearer "
):]
print
(
"ANTES DEL IF--------------"
)
if
not
token
or
token
!=
CHAT_SESSIONS
[
session_id
][
"token"
]:
if
not
token
or
token
!=
CHAT_SESSIONS
[
session_id
][
"token"
]:
print
(
f
"TOKEN : {token} ----- GUARDADO : {CHAT_SESSIONS[session_id]["
token
"]}"
)
return
jsonify
({
"error"
:
"Token inválido para esta sesión"
}),
401
return
jsonify
({
"error"
:
"Token inválido para esta sesión"
}),
401
chat
=
CHAT_SESSIONS
[
session_id
][
"chat"
]
chat
=
CHAT_SESSIONS
[
session_id
][
"chat"
]
...
@@ -143,7 +144,6 @@ def get_recipe_detail(index: int):
...
@@ -143,7 +144,6 @@ def get_recipe_detail(index: int):
session_recipes
=
session_data
.
get
(
"recipes"
,
[])
session_recipes
=
session_data
.
get
(
"recipes"
,
[])
if
index
<
0
or
index
>=
len
(
session_recipes
):
if
index
<
0
or
index
>=
len
(
session_recipes
):
print
(
f
"INDEX : {index} ------ LONGITUD : {len(session_recipes)}"
)
return
jsonify
({
"error"
:
"Índice de receta fuera de rango"
}),
400
return
jsonify
({
"error"
:
"Índice de receta fuera de rango"
}),
400
# Comprobar si ya tenemos el detalle
# Comprobar si ya tenemos el detalle
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment