File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -56,21 +56,25 @@ def verifica_cep(cep):
5656
5757@route ('/v1/track/ect/<track>' )
5858def track_ect (track ):
59- encomenda = Correios .encomenda (track )
59+ try :
60+ encomenda = Correios .encomenda (track )
61+
62+ result = []
6063
61- result = []
64+ for status in encomenda .status :
65+ resposta = dict ()
66+
67+ resposta ['data' ] = status .data
68+ resposta ['local' ] = status .local
69+ resposta ['situacao' ] = status .situacao
70+ resposta ['detalhes' ] = status .detalhes
6271
63- for status in encomenda .status :
64- resposta = dict ()
65-
66- resposta ['data' ] = status .data
67- resposta ['local' ] = status .local
68- resposta ['situacao' ] = status .situacao
69- resposta ['detalhes' ] = status .detalhes
72+ result .append (resposta )
7073
71- result . append ( resposta )
74+ return json . dumps ( result )
7275
73- return json .dumps (result )
76+ except AttributeError :
77+ response .status = '404 O pacote %s informado não pode ser localizado' % track
7478
7579def _standalone (port = 9876 ):
7680 run (host = 'localhost' , port = port )
You can’t perform that action at this time.
0 commit comments