File size: 5,386 Bytes
2851db2
 
 
76c54ac
0537c68
6ea1ae1
76c54ac
ce3761d
76c54ac
 
 
 
 
 
 
ce3761d
d4812c0
2851db2
 
 
 
 
 
 
 
 
76c54ac
2851db2
ce3761d
 
 
d4812c0
ce3761d
 
 
 
 
 
 
 
 
 
 
 
 
 
d4812c0
ce3761d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4812c0
ce3761d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4812c0
ce3761d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4812c0
ce3761d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4812c0
ce3761d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4812c0
ce3761d
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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['message']= "Bienvenido"
    except Exception as e:
        print(e)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response

@api.post("/texto_desde_web/", 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)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response

@api.post("/texto_desde_pdf/", status_code=201)
def __get_text_from_pdf(data:dict) -> dict:
    __response=dict({"request_data":data})
    try:
        if data:
            __response['texto']=__main.obtener_texto(from_pdf=data.get('pdf'))
        else:
            raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
    except Exception as e:
        print(e)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response

@api.post("/generar_bloques/", status_code=201)
def __get_blocks(data:dict) -> dict:
    __response=dict({"request_data":data})
    try:
        if data:
            __response['original']=data.get('texto')
            __response['bloques']=__main.generar_bloques(texto=data.get('texto'),
                                                         s=data.get('size'))
        else:
            raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
    except Exception as e:
        print(e)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response

@api.post("/traducir/", status_code=201)
def __get_traduccion(data:dict) -> dict:
    __response=dict({"request_data":data})
    try:
        if data:
            __response['original']= data.get('texto')
            __response['traduccion']= __main.traducir(texto=data.get('texto'),
                                                      idioma="EN/ES")
        else:
            raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
    except Exception as e:
        print(e)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response

@api.post("/resumir/", status_code=201)
def __get_resumen(data:dict) -> dict:
    __response=dict({"request_data":data})
    try:
        if data:
            __response['original']= data.get('texto')
            __response['resumen']= __main.resumir(texto=data.get('texto'))
        else:
            raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
    except Exception as e:
        print(e)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response
    
@api.post("/texto_a_imagen/", status_code=201)
def __get_text2img(data:dict) -> dict:
    __response=dict({"request_data":data})
    try:
        if data:
            __response['original']= data.get('texto')
            __response['image']= __main.text_to_img(texto=data.get('texto'))
        else:
            raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
    except Exception as e:
        print(e)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response

@api.post("/texto_a_video/", status_code=201)
def __get_text2video(data:dict) -> dict:
    __response=dict({"request_data":data})
    try:
        if data:
            __response['original']= data.get('texto')
            __response['video']= __main.text_to_video(texto=data.get('texto'))
        else:
            raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
    except Exception as e:
        print(e)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response

@api.post("/texto_a_audio/", status_code=201)
def __get_text2speach(data:dict) -> dict:
    __response=dict({"request_data":data})
    try:
        if data:
            __response['original']= data.get('texto')
            __response['audio']= __main.text_to_speach(texto=data.get('texto'))
        else:
            raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
    except Exception as e:
        print(e)
        #To-do ->agregar mas información en el error fecha, usuario, reqs
        raise __main.exception(status_code = 403, datail=e)
    finally:
        return __response