Spaces:
Sleeping
Sleeping
Moibe commited on
Commit ·
2647683
1
Parent(s): a6c4531
Debit tokens modernized estructure
Browse files- funciones.py +2 -2
- main.py +5 -7
funciones.py
CHANGED
|
@@ -64,14 +64,14 @@ def authorize(tokens, work):
|
|
| 64 |
|
| 65 |
return result
|
| 66 |
|
| 67 |
-
def debitTokens(userfile, work):
|
| 68 |
|
| 69 |
print(f"Task received : {work}, type: {type(work)} ...")
|
| 70 |
|
| 71 |
#Genera conexión inicial.
|
| 72 |
sshListo, sftpListo = avaimet.conecta()
|
| 73 |
#Obtiene la caja donde está guardados los tokens.
|
| 74 |
-
caja = avaimet.obtenCaja(userfile)
|
| 75 |
#Obtiene los tokens que hay en esa caja.
|
| 76 |
tokens = avaimet.obtenTokens(sftpListo, caja)
|
| 77 |
#Aplica las reglas de ésta app para debitar lo correspondiente.
|
|
|
|
| 64 |
|
| 65 |
return result
|
| 66 |
|
| 67 |
+
def debitTokens(userfile, work, env):
|
| 68 |
|
| 69 |
print(f"Task received : {work}, type: {type(work)} ...")
|
| 70 |
|
| 71 |
#Genera conexión inicial.
|
| 72 |
sshListo, sftpListo = avaimet.conecta()
|
| 73 |
#Obtiene la caja donde está guardados los tokens.
|
| 74 |
+
caja = avaimet.obtenCaja(userfile, env)
|
| 75 |
#Obtiene los tokens que hay en esa caja.
|
| 76 |
tokens = avaimet.obtenTokens(sftpListo, caja)
|
| 77 |
#Aplica las reglas de ésta app para debitar lo correspondiente.
|
main.py
CHANGED
|
@@ -51,17 +51,15 @@ def authorize(tokens: int, work: str = "picswap"):
|
|
| 51 |
|
| 52 |
## DEBIT TOKENS ##
|
| 53 |
#Vía Parámeters
|
| 54 |
-
@app.get("/debitTokens/{userfile}/{work}")
|
| 55 |
-
def debitTokens(userfile: str, work: str):
|
| 56 |
-
tokens = funciones.debitTokens(userfile,work)
|
| 57 |
-
#print("Tipo de resultado:", type(tokens))
|
| 58 |
return tokens
|
| 59 |
|
| 60 |
#Vía Query
|
| 61 |
@app.get("/debitTokensQ/")
|
| 62 |
-
def debitTokens(userfile: str, work: str = "picswap"):
|
| 63 |
-
tokens = funciones.debitTokens(userfile,work)
|
| 64 |
-
#print("Tipo de resultado:", type(tokens))
|
| 65 |
return tokens
|
| 66 |
|
| 67 |
## GET USER Novelty ##
|
|
|
|
| 51 |
|
| 52 |
## DEBIT TOKENS ##
|
| 53 |
#Vía Parámeters
|
| 54 |
+
@app.get("/debitTokens/{userfile}/{work}/{env}")
|
| 55 |
+
def debitTokens(userfile: str, work: str, env: str):
|
| 56 |
+
tokens = funciones.debitTokens(userfile,work, env)
|
|
|
|
| 57 |
return tokens
|
| 58 |
|
| 59 |
#Vía Query
|
| 60 |
@app.get("/debitTokensQ/")
|
| 61 |
+
def debitTokens(userfile: str, work: str = "picswap", env: str = "dev"):
|
| 62 |
+
tokens = funciones.debitTokens(userfile,work, env)
|
|
|
|
| 63 |
return tokens
|
| 64 |
|
| 65 |
## GET USER Novelty ##
|