def main(): # reads input parameters form = cgi.FieldStorage() # from latitude and longiture as input parameters return national and # meteo links lat = float(form.getfirst("lat")) lon = float(form.getfirst("lon")) # return national and meteo links for the selected point response = _returnNationalLinks(lat, lon) response["error"] = '' response["result"] = '1' print(json.JSONEncoder().encode(response)) if __name__ == "__main__": cgitb.enable() print "Content-type: application/json" print try: main() except: #_writeTrace(str(sys.exc_info())) strError = 'There was an error with the request. Pleae, try again.' logger.exception(strError) response = {'result': 0, 'error': strError} print(json.JSONEncoder().encode(response))
kill $pid. This script executes the content and delete the file. """ from mdlFunctions import _killPid from mdlFunctions import logger import sys import json #from mdlFunctions import _writeTrace def main(): arrayParams = json.load(sys.stdin) print arrayParams # kill the pid _killPid(arrayParams["strFile"]) # delete the temporary file #_deleteFile(arrayParams["strFile"]) if __name__ == "__main__": print "Content-Type: text/plain;charset=utf-8" print # read input parameters try: main() except: logger.exception() #_writeTrace(str(sys.exc_info()))
arrayFName["type"]) # retunr Legend image of getLegend using WMS strLegend = _returnLegendString(arrayFName, arrayVDataset, strDateCoverage) # response response["description"] = arrayFName["description"] response["legendLink"] = strLegend # response["metadataLink"]=_returnMetadataLink(arrayFName["id"]) response["id"] = arrayFName["id"] response['result'] = 1 response['error'] = '' # print the output json array print(json.JSONEncoder().encode(response)) if __name__ == "__main__": cgitb.enable() try: print "Content-type: application/json" print main() except: #_writeTrace(str(sys.exc_info())) strError = 'There was an error with the request. Pleae, try again.' logger.exception(strError) response = {'result': 0, 'error': strError} print(json.JSONEncoder().encode(response))