|
import funciones |
|
from fastapi import FastAPI, Form |
|
from fastapi import FastAPI, File, UploadFile |
|
from typing import Literal |
|
from fastapi.responses import JSONResponse |
|
|
|
app = FastAPI() |
|
|
|
|
|
@app.get("/health", |
|
tags=["Health Check"], |
|
description="Verifica el estado de salud de la API.", |
|
summary="Health Check" |
|
) |
|
async def health_check(): |
|
""" |
|
Este endpoint devuelve una respuesta 200 OK para indicar que la API está funcionando. |
|
""" |
|
return JSONResponse(content={"status": "ok"}, status_code=200) |
|
|
|
@app.post("/partynight/") |
|
async def partynight( |
|
image: UploadFile = File(...), |
|
outfit_color: Literal["red", "black", "blue", "golden", "pink", "green", "yellow", "purple", "silver", "white", "sky blue", "light blue", "royal blue", "navy blue", "orange", "random", ""] = Form(None) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_partynight(image, outfit_color) |
|
|
|
@app.post("/babydoll/") |
|
async def babydoll( |
|
image: UploadFile = File(...), |
|
outfit_color: Literal["red", "black", "blue", "golden", "pink", "green", "yellow", "purple", "silver", "white", "sky blue", "light blue", "royal blue", "navy blue", "orange", "random", ""] = Form(None) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_babydoll(image, outfit_color) |
|
|
|
@app.post("/leather/") |
|
async def leather( |
|
image: UploadFile = File(...) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_leather(image) |
|
|
|
@app.post("/stewardess/") |
|
async def stewardess( |
|
image: UploadFile = File(...), |
|
color: Literal["red", "black", "blue", "golden", "pink", "green", "yellow", "purple", "silver", "white", "sky blue", "light blue", "royal blue", "navy blue", "orange", "random", ""] = Form(None)): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_stewardess(image, color) |
|
|
|
@app.post("/oktoberfest/") |
|
async def oktoberfest( |
|
image: UploadFile = File(...) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_oktoberfest(image) |
|
|
|
@app.post("/ghibli/") |
|
async def ghibli( |
|
image: UploadFile = File(...) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_ghibli(image) |
|
|
|
@app.post("/wildwest/") |
|
async def wildwest( |
|
image: UploadFile = File(...) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_wildwest(image) |
|
|
|
@app.post("/bride/") |
|
async def bride( |
|
image: UploadFile = File(...) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_bride(image) |
|
|
|
@app.post("/swimsuit/") |
|
async def swimsuit( |
|
image: UploadFile = File(...), |
|
color: Literal["red", "black", "blue", "golden", "pink", "green", "yellow", "purple", "silver", "white", "sky blue", "light blue", "royal blue", "navy blue", "orange", "random", ""] = Form(None) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_swimsuit(image, color) |
|
|
|
@app.post("/lingerie/") |
|
async def lingerie( |
|
image: UploadFile = File(...) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_lingerie(image) |
|
|
|
@app.post("/schooluniform/") |
|
async def schooluniform( |
|
image: UploadFile = File(...) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_schooluniform(image) |
|
|
|
@app.post("/frenchmaid/") |
|
async def frenchmaid( |
|
image: UploadFile = File(...) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_frenchmaid(image) |
|
|
|
@app.post("/cheerleader/") |
|
async def cheerleader( |
|
image: UploadFile = File(...), |
|
color: Literal["red", "black", "blue", "golden", "pink", "green", "yellow", "purple", "silver", "white", "sky blue", "light blue", "royal blue", "navy blue", "orange", "random", ""] = Form(None), |
|
hairstyle: Literal["ponytail", "pigtails", "random", ""] = Form(None) |
|
): |
|
if not image.content_type.startswith("image/"): |
|
return {"error": "The file is not an image."} |
|
return await funciones.crea_cheerleader(image, color, hairstyle) |