import os.path
import time
import Handler
from Handler import PATH_XML_DOCS
import jon.cgi as cgi
import jon.modpy as modpy

class ReloadHandler(Handler.Handler):
   
    def view(self, req):
        req.set_header('Content-Type', 'text/html')
        req.set_header('Cache-Control', 'max-age=0')
        req.set_header('Cache-Control', 'no-cache')
        req.set_header('expires', '0')
        req.set_header('Expires', 'Tue, 01 Jan 1980 1:00:00 GMT')
        req.set_header('Pragma', 'no-cache')
        req.write(os.path.getmtime(PATH_XML_DOCS + 'asimux.xml') > time.time() - 5)
    
#cgi.CGIRequest(ReloadHandler).process()
def handler(modpy_request):
    return modpy.Request(ReloadHandler).process(modpy_request)