|
from api.core.app import Demos |
|
__main = Demos() |
|
api = __main.api() |
|
@api.get("/", status_code=201) |
|
def home() -> dict: |
|
__response=dict({"request_data":None}) |
|
try: |
|
__response['texto']= "hola" |
|
except Exception as e: |
|
print(e) |
|
|
|
raise __main.exception(status_code = 403, datail=e) |
|
finally: |
|
return __response |
|
|
|
@api.post("/obtener_texto/", status_code=201) |
|
def get_text_from_url(data:dict) -> dict: |
|
__response=dict({"request_data":data}) |
|
try: |
|
if data: |
|
__response['texto']=__main.obtener_texto(from_url=data.get('url')) |
|
else: |
|
raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}") |
|
except Exception as e: |
|
print(e) |
|
|
|
raise __main.exception(status_code = 403, datail=e) |
|
finally: |
|
return __response |