@request.restful()
def icd10():
import libxml2
icd10_xml = libxml2.parseDoc(open('/home/www-data/web2py/applications'+URL('static','icd10/icd10cm/Tabular.xml'),'r').read())
response.view = 'generic.xml'
def GET(**vars):
search_str = request.vars.search
xpath_req = '//chapter/section/diag/desc[contains(text(),"'+search_str+'")]'
diags = icd10_xml.xpathEval(xpath_req)
concat = '<?xml version="1.0" encoding="utf-8"?><main>'
for diag in diags:
diag_str = str(XML(diag))
concat = concat + diag_str
concat = concat + '</main>'
return concat
return locals()
Anthony
https://localhost/testapp/api/icd10.xml?search=string
Thanks for your input.
I removed the response.view and added the xml extension in the request:
https://localhost/testapp/api/icd10.xml?search=string
and it worked. Is there any way to get an xml view without adding the xml extension?