|
|
from fastapi import FastAPI, UploadFile, File
|
|
|
from PIL import Image
|
|
|
import pytesseract
|
|
|
from serpapi import GoogleSearch
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
|
@app.get("/")
|
|
|
def raiz():
|
|
|
return {"Mensaje": "¡V3G4 funciona! Creada por 4n0n1m0-117"}
|
|
|
|
|
|
|
|
|
@app.post("/buscar")
|
|
|
async def buscar(query: str):
|
|
|
params = {
|
|
|
"q": query,
|
|
|
"api_key": "ea1f3826de0370e1421bbb257b5a03e30aaa6ae084f656742935a13a3a8a65a2",
|
|
|
"engine": "google"
|
|
|
}
|
|
|
search = GoogleSearch(params)
|
|
|
results = search.get_dict()
|
|
|
return {"respuesta": results["organic_results"][0]["snippet"]}
|
|
|
|
|
|
|
|
|
@app.post("/analizar-imagen")
|
|
|
async def analizar_imagen(imagen: UploadFile = File(...)):
|
|
|
img = Image.open(imagen.file)
|
|
|
texto = pytesseract.image_to_string(img)
|
|
|
return {"texto": texto}
|
|
|
|
|
|
from fastapi import FastAPI, UploadFile, File
|
|
|
from PIL import Image
|
|
|
import pytesseract
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
|
@app.get("/")
|
|
|
def raiz():
|
|
|
return {"Mensaje": "¡V3G4 funciona! Creada por 4n0n1m0-117"}
|
|
|
|
|
|
|
|
|
@app.post("/analizar-imagen")
|
|
|
async def analizar_imagen(imagen: UploadFile = File(...)):
|
|
|
img = Image.open(imagen.file)
|
|
|
texto = pytesseract.image_to_string(img)
|
|
|
return {"texto": texto}
|
|
|
|
|
|
|
|
|
import firebase_admin
|
|
|
from firebase_admin import auth, credentials
|
|
|
|
|
|
cred = credentials.Certificate("/app/firebase-key.json")
|
|
|
firebase_admin.initialize_app(cred)
|
|
|
|
|
|
@app.post("/login")
|
|
|
async def login(token: str):
|
|
|
try:
|
|
|
usuario = auth.verify_id_token(token)
|
|
|
return {"uid": usuario["uid"]}
|
|
|
except:
|
|
|
return {"error": "Autenticación fallida"}
|
|
|
|
|
|
|