Spaces:
Running
Running
Added SulkuPypi
Browse files- app.py +5 -0
- sulkuPypi.py +93 -0
app.py
CHANGED
|
@@ -3,9 +3,14 @@ from PIL import Image
|
|
| 3 |
import time
|
| 4 |
import os
|
| 5 |
import pathlib
|
|
|
|
| 6 |
|
| 7 |
def perform(input1, input2):
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
#video o cualquier otro ser铆a para imagenes.
|
| 10 |
modo = "pic"
|
| 11 |
#local o huggingface
|
|
|
|
| 3 |
import time
|
| 4 |
import os
|
| 5 |
import pathlib
|
| 6 |
+
import sulkuPypi
|
| 7 |
|
| 8 |
def perform(input1, input2):
|
| 9 |
|
| 10 |
+
#Primero que nada, checa cuantos tokens:
|
| 11 |
+
tokens = sulkuPypi.getTokens("gAAAAABmEZA4SLBC2YczouOrjIEi9WNCNGOIvyUcqBUnzxNsftXTdy54KaX9x8mAjFkABSI6FJrdZDQKk_5lpJOgJoMChxlniw==")
|
| 12 |
+
print(f"Tienes: {tokens} tokens. ")
|
| 13 |
+
|
| 14 |
#video o cualquier otro ser铆a para imagenes.
|
| 15 |
modo = "pic"
|
| 16 |
#local o huggingface
|
sulkuPypi.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
base_url = "https://moibe-sulku-fastapi-docker.hf.space/"
|
| 5 |
+
userfile = "gAAAAABmEZA4SLBC2YczouOrjIEi9WNCNGOIvyUcqBUnzxNsftXTdy54KaX9x8mAjFkABSI6FJrdZDQKk_5lpJOgJoMChxlniw=="
|
| 6 |
+
#Ojo, cuando el userfile termina con s铆mbolo igual y supongo que tambi茅n si empieza, causa problemas, la soluci贸n, ...
|
| 7 |
+
#... implementar m谩s adelante desde ser agregar un caract茅r delimitador y desp煤es quitarlo, esto para evitar problemas...
|
| 8 |
+
#... con el s铆mbolo =, ? y &. Dicho problema solo sucede cuando lo recibe como query params no como path params.
|
| 9 |
+
work = "picswap"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def getTokens(userfile):
|
| 13 |
+
|
| 14 |
+
method = "getTokens/"
|
| 15 |
+
|
| 16 |
+
api_url = base_url + method + userfile
|
| 17 |
+
|
| 18 |
+
response = requests.get(api_url)
|
| 19 |
+
|
| 20 |
+
if response.status_code == 200:
|
| 21 |
+
print("Conexi贸n a Sulku successful...")
|
| 22 |
+
tokens = response.json()
|
| 23 |
+
print("Tokens:", tokens)
|
| 24 |
+
else:
|
| 25 |
+
print("Error al obtener el elemento todo:", response.status_code)
|
| 26 |
+
|
| 27 |
+
return tokens
|
| 28 |
+
|
| 29 |
+
def authorize(tokens, work):
|
| 30 |
+
|
| 31 |
+
method = "authorize/"
|
| 32 |
+
|
| 33 |
+
api_url = base_url + method + str(tokens) + "/" + work
|
| 34 |
+
|
| 35 |
+
print("Apiurl es: ", api_url)
|
| 36 |
+
|
| 37 |
+
response = requests.get(api_url)
|
| 38 |
+
|
| 39 |
+
if response.status_code == 200:
|
| 40 |
+
print("Conexi贸n a Sulku successful...")
|
| 41 |
+
autorizacion = response.json()
|
| 42 |
+
print("Autorizaci贸n:", autorizacion)
|
| 43 |
+
else:
|
| 44 |
+
print("Error al obtener el elemento todo:", response.status_code)
|
| 45 |
+
|
| 46 |
+
return autorizacion
|
| 47 |
+
|
| 48 |
+
def debitTokens(userfile, work):
|
| 49 |
+
|
| 50 |
+
method = "debitTokens/"
|
| 51 |
+
|
| 52 |
+
api_url = base_url + method + userfile + "/" + work
|
| 53 |
+
|
| 54 |
+
print("Apiurl es: ", api_url)
|
| 55 |
+
|
| 56 |
+
response = requests.get(api_url)
|
| 57 |
+
|
| 58 |
+
if response.status_code == 200:
|
| 59 |
+
print("Conexi贸n a Sulku successful...")
|
| 60 |
+
tokens = response.json()
|
| 61 |
+
print("Tokens:", tokens)
|
| 62 |
+
else:
|
| 63 |
+
print("Error al obtener el elemento todo:", response.status_code)
|
| 64 |
+
|
| 65 |
+
return tokens
|
| 66 |
+
|
| 67 |
+
def debitTokensQ(userfile, work):
|
| 68 |
+
|
| 69 |
+
#debitTokens pero con QueryParams, (los query params sirve para ocasiones en los que usas dos de un mismo query param para abtener el resultado de un AND o rangos como...
|
| 70 |
+
#... clima por ejemplo.)
|
| 71 |
+
method = "debitTokens?"
|
| 72 |
+
|
| 73 |
+
api_url = base_url + method + "userfile=" + userfile + "&" + "work=" + work
|
| 74 |
+
|
| 75 |
+
print("Apiurl es: ", api_url)
|
| 76 |
+
|
| 77 |
+
response = requests.get(api_url)
|
| 78 |
+
|
| 79 |
+
if response.status_code == 200:
|
| 80 |
+
print("Conexi贸n a Sulku successful...")
|
| 81 |
+
tokens = response.json()
|
| 82 |
+
print("Tokens:", tokens)
|
| 83 |
+
else:
|
| 84 |
+
print("Error al obtener el elemento todo:", response.status_code)
|
| 85 |
+
|
| 86 |
+
return tokens
|
| 87 |
+
|
| 88 |
+
if __name__ == "__main__":
|
| 89 |
+
getTokens(userfile)
|
| 90 |
+
authorize(18,'picswap')
|
| 91 |
+
debitTokens(userfile, work)
|
| 92 |
+
#debitTokensQ(userfile, work)
|
| 93 |
+
#pass
|