Esempio n. 1
0
 def WriteResponsePyHTMLFile(self, filepath, headers=None):
     if "MicroWebTemplate" in globals():
         with open(filepath, "r") as file:
             code = file.read()
         gc.collect()
         mWebTmpl = MicroWebTemplate(code, escapeStrFunc=MicroWebSrv.HTMLEscape, filepath=filepath)
         try:
             tmplResult = mWebTmpl.Execute()
             return self.WriteResponse(200, headers, "text/html", "UTF-8", tmplResult)
         except Exception as ex:
             return self.WriteResponse(
                 500, None, "text/html", "UTF-8", self._execErrCtnTmpl % {"module": "PyHTML", "message": str(ex)}
             )
     return self.WriteResponseNotImplemented()
Esempio n. 2
0
 def WriteResponsePyHTMLFile(self, filepath, headers=None):
     if 'MicroWebTemplate' in globals():
         with open(filepath, 'r') as file:
             code = file.read()
         mWebTmpl = MicroWebTemplate(
             code, escapeStrFunc=self._client._microWebSrv.HTMLEscape)
         try:
             return self.WriteResponseOk(headers, "text/html", "UTF-8",
                                         mWebTmpl.Execute())
         except:
             return self.WriteResponse(
                 500, None, "text/html", "UTF-8",
                 self._execErrCtnTmpl % {
                     'module': 'PyHTML',
                     'message': exc_info()[1]
                 })
     return self.WriteResponseNotImplemented()
     def WriteResponsePyHTMLFile(self, filepath, headers=None, vars=None) :
         if 'MicroWebTemplate' in globals() :
             with open(filepath, 'r') as file :
                 code = file.read()
             mWebTmpl = MicroWebTemplate(code, escapeStrFunc=MicroWebSrv.HTMLEscape, filepath=filepath)
             try :
                 tmplResult = mWebTmpl.Execute(None, vars)
                 return self.WriteResponse(200, headers, "text/html", "UTF-8", tmplResult)
             except Exception as ex :
                 return self.WriteResponse( 500,
 	                                       None,
 	                                       "text/html",
 	                                       "UTF-8",
 	                                       self._execErrCtnTmpl % {
 	                                            'module'  : 'PyHTML',
 	                                            'message' : str(ex)
 	                                       } )
         return self.WriteResponseNotImplemented()