File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 22# -*- coding: utf-8 -*-
33import bottle
44import json
5+ import xmltodict
56from bottle import route , run , response
67from CepTracker import CepTracker
78import requests
@@ -36,6 +37,12 @@ def format_result(result):
3637 # checa se foi solicitada resposta em JSONP
3738 js_func_name = bottle .request .query .get (jsonp_query_key )
3839
40+ #checa se foi solicitado xml
41+ format = bottle .request .query .get ('format' )
42+ if format == 'xml' :
43+ response .content_type = 'application/xml'
44+ return xmltodict .unparse ({'result' : result })
45+
3946 if js_func_name :
4047 # se a resposta vai ser JSONP, o content type deve ser js e seu
4148 # conteudo deve ser JSON
@@ -71,7 +78,6 @@ def verifica_cep(cep):
7178 result = db .get_one (cep , fields = {'_id' : False , 'v_date' : False })
7279
7380 if result :
74-
7581 response .headers ['Cache-Control' ] = 'public, max-age=2592000'
7682 return format_result (result )
7783 else :
You can’t perform that action at this time.
0 commit comments