Spaces:
Running
Running
Endpoint: crearLinkSesion
Browse files- .gitignore +0 -1
- app.py +11 -11
- autenticacion.py +7 -8
- bridges..py +0 -1
- bridges.py +2 -1
- funciones.py +1 -2
- globales.py +1 -1
- herramientas.py +7 -8
.gitignore
CHANGED
@@ -2,4 +2,3 @@
|
|
2 |
/__pycache__/
|
3 |
bridges.py
|
4 |
config.json
|
5 |
-
config_old.json
|
|
|
2 |
/__pycache__/
|
3 |
bridges.py
|
4 |
config.json
|
|
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
import herramientas
|
2 |
-
from io import BytesIO
|
3 |
import funciones, globales
|
4 |
from fastapi import FastAPI, Form
|
5 |
from fastapi import FastAPI, File, UploadFile
|
6 |
from fastapi.responses import StreamingResponse, FileResponse, JSONResponse
|
|
|
|
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
@@ -19,12 +19,12 @@ async def health_check():
|
|
19 |
"""
|
20 |
return JSONResponse(content={"status": "ok"}, status_code=200)
|
21 |
|
22 |
-
@app.post("/
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
1 |
import funciones, globales
|
2 |
from fastapi import FastAPI, Form
|
3 |
from fastapi import FastAPI, File, UploadFile
|
4 |
from fastapi.responses import StreamingResponse, FileResponse, JSONResponse
|
5 |
+
from fastapi import FastAPI, Form
|
6 |
+
from typing import Optional # Importa Optional
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
|
|
19 |
"""
|
20 |
return JSONResponse(content={"status": "ok"}, status_code=200)
|
21 |
|
22 |
+
@app.post("/creaLinkSesion/")
|
23 |
+
async def creaLinkSesion(
|
24 |
+
price_id: str = Form(...), # Sigue siendo requerido, enviado como Form si la petición es multipart/form-data
|
25 |
+
customer_email: Optional[str] = Form(None), # Ahora opcional, valor por defecto None
|
26 |
+
customer_id: Optional[str] = Form(None) # Ahora opcional, valor por defecto None
|
27 |
+
):
|
28 |
+
return funciones.create_checkout_session(price_id, customer_email, customer_id)
|
29 |
+
|
30 |
+
|
autenticacion.py
CHANGED
@@ -4,22 +4,21 @@ import socket
|
|
4 |
def defineAmbiente():
|
5 |
if local_check():
|
6 |
print("Entorno Local...")
|
7 |
-
|
8 |
-
llave =
|
9 |
-
|
10 |
else:
|
11 |
print("Entorno remoto listo...")
|
12 |
-
llave = os.getenv("llave")
|
13 |
-
|
14 |
-
|
15 |
-
return llave, servidor
|
16 |
|
17 |
def local_check():
|
18 |
hostname = socket.gethostname()
|
19 |
#r-moibe-nowme
|
20 |
print("Hostname: ", hostname)
|
21 |
#Estoy usando el nombre de la app para identificar que estoy corriendola en HF.
|
22 |
-
if "
|
23 |
print("Ejecutando api en el servidor.")
|
24 |
return False
|
25 |
else:
|
|
|
4 |
def defineAmbiente():
|
5 |
if local_check():
|
6 |
print("Entorno Local...")
|
7 |
+
import bridges
|
8 |
+
llave = bridges.llave
|
9 |
+
|
10 |
else:
|
11 |
print("Entorno remoto listo...")
|
12 |
+
llave = os.getenv("llave")
|
13 |
+
|
14 |
+
return llave
|
|
|
15 |
|
16 |
def local_check():
|
17 |
hostname = socket.gethostname()
|
18 |
#r-moibe-nowme
|
19 |
print("Hostname: ", hostname)
|
20 |
#Estoy usando el nombre de la app para identificar que estoy corriendola en HF.
|
21 |
+
if "stripe" in hostname:
|
22 |
print("Ejecutando api en el servidor.")
|
23 |
return False
|
24 |
else:
|
bridges..py
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
#Bridges
|
|
|
|
bridges.py
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
#Bridges
|
|
|
|
1 |
+
#Bridges
|
2 |
+
llave = "sk_test_UEqlnnbMITO2SqRQ10ZJh33P"
|
funciones.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import globales
|
2 |
import herramientas
|
3 |
import conexion_firebase
|
|
|
4 |
|
5 |
def funcion_generica(platillo):
|
6 |
-
|
7 |
try:
|
8 |
return "Hola"
|
9 |
|
@@ -25,7 +25,6 @@ def create_checkout_session(price_id, customer_email=None, customer_id=None):
|
|
25 |
Returns:
|
26 |
str: La URL de la Checkout Session, o None si hay un error.
|
27 |
"""
|
28 |
-
print("Estoy en create checkout session y el customer ID es: ", customer_id)
|
29 |
try:
|
30 |
session_params = {
|
31 |
'line_items': [{
|
|
|
1 |
import globales
|
2 |
import herramientas
|
3 |
import conexion_firebase
|
4 |
+
import stripe
|
5 |
|
6 |
def funcion_generica(platillo):
|
|
|
7 |
try:
|
8 |
return "Hola"
|
9 |
|
|
|
25 |
Returns:
|
26 |
str: La URL de la Checkout Session, o None si hay un error.
|
27 |
"""
|
|
|
28 |
try:
|
29 |
session_params = {
|
30 |
'line_items': [{
|
globales.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import autenticacion
|
2 |
version = "0.0.0"
|
3 |
|
4 |
-
llave
|
5 |
|
|
|
1 |
import autenticacion
|
2 |
version = "0.0.0"
|
3 |
|
4 |
+
llave = autenticacion.defineAmbiente()
|
5 |
|
herramientas.py
CHANGED
@@ -1,21 +1,20 @@
|
|
1 |
from datetime import datetime
|
2 |
from datetime import datetime
|
3 |
import conexion_firebase
|
4 |
-
import globales
|
5 |
import pytz
|
6 |
|
7 |
-
if globales.servidor == "moibe":
|
8 |
-
|
9 |
-
|
10 |
-
else:
|
11 |
-
|
12 |
-
|
13 |
|
14 |
def obtenUltimoTimestamp():
|
15 |
"""
|
16 |
Obtiene el último timestamp de renovación guardado.
|
17 |
"""
|
18 |
-
resultado = conexion_firebase.obtenDato('nowme', 'huggingface', last_timestamp)
|
19 |
|
20 |
return resultado
|
21 |
|
|
|
1 |
from datetime import datetime
|
2 |
from datetime import datetime
|
3 |
import conexion_firebase
|
|
|
4 |
import pytz
|
5 |
|
6 |
+
# if globales.servidor == "moibe":
|
7 |
+
# segundos = "segundos_dev"
|
8 |
+
# last_timestamp = "last_timestamp_dev"
|
9 |
+
# else:
|
10 |
+
# segundos = "segundos_prod"
|
11 |
+
# last_timestamp = "last_timestamp_prod"
|
12 |
|
13 |
def obtenUltimoTimestamp():
|
14 |
"""
|
15 |
Obtiene el último timestamp de renovación guardado.
|
16 |
"""
|
17 |
+
resultado = "hola placeholder" #conexion_firebase.obtenDato('nowme', 'huggingface', last_timestamp)
|
18 |
|
19 |
return resultado
|
20 |
|