def index(self): print "(index) Got view_days=%s" % self.view_days download_email(environ, '%s/assets/images' % myDir) update_time = strftime("%Y-%m-%d %H:%M:%S", localtime()) print "update: %s" % update_time HTML_LIST = '' self.the_images = get_images("%s/assets/images/" % myDir, self.view_days) if len(self.the_images) > 0: for image in self.the_images: HTML_LIST += '\r\ <div class="container">\r\ <img src="/assets/images/%s">\r\ </div>\r\ <br>\r\ ' % image["name"] else: HTML_LIST = '\r\ <div class="container">\r\ <p class="lead">Inga bilder!</p>\r\ </div>\r\ <br>\r' HTML_BODY = '\r\ \r\ <div class="container">\r\ \r\ <div class="starter-template">\r\ <br>\r\ <p class="lead">Hittade <strong>%s</strong> bilder, senast uppdaterad <strong>%s</strong></p>\r\ </div>\r\ \r\ <div>\r\ %s\r\ </div>\r\ \r\ </div><!-- /.container -->\r\ ' % (len(self.the_images), update_time, HTML_LIST) return "%s%s%s%s" % (HTML_HEADER, html_navbar( self.view_days), HTML_BODY, HTML_FOOTER)
def index(self): print "(index) Got view_days=%s"% self.view_days download_email(myDir) update_time = strftime("%Y-%m-%d %H:%M:%S", localtime()) print "update: %s"% update_time HTML_LIST='' the_images = get_images("%s/assets/images/"% myDir, self.view_days) if len(the_images) > 0: for image in the_images: HTML_LIST += '\r\ <div class="container">\r\ <img src="/assets/images/%s">\r\ </div>\r\ <br>\r\ '% image["name"] else: HTML_LIST = '\r\ <div class="container">\r\ <p class="lead">Inga bilder!</p>\r\ </div>\r\ <br>\r' HTML_BODY = '\r\ \r\ <div class="container">\r\ \r\ <div class="starter-template">\r\ <br>\r\ <p class="lead">Hittade <strong>%s</strong> bilder, senast uppdaterad <strong>%s</strong></p>\r\ </div>\r\ \r\ <div>\r\ %s\r\ </div>\r\ \r\ </div><!-- /.container -->\r\ '% (len(the_images), update_time, HTML_LIST) return "%s%s%s%s"%(HTML_HEADER, html_navbar(self.view_days), HTML_BODY, HTML_FOOTER)
</div>\r\ \r\ </div><!-- /.container -->\r\ ' % (len(self.the_images), update_time, HTML_LIST) return "%s%s%s%s" % (HTML_HEADER, html_navbar( self.view_days), HTML_BODY, HTML_FOOTER) conf = { '/': { 'tools.sessions.on': True, 'tools.staticdir.root': myDir }, '/assets': { 'tools.staticdir.on': True, 'tools.staticdir.dir': './assets' } } cherrypy.config.update({'server.socket_host': ip, 'server.socket_port': port}) if len(get_images("%s/assets/images/" % myDir)) == 0: print "No images...pulling all" download_email(environ, "%s/assets/images/" % myDir, 'ALL') cherrypy.quickstart(GrisVakt(), '/', conf) #server = wsgiserver.CherryPyWSGIServer((ip, port), wsgi.application, server_name=host_name) #server.start()
</div>\r\ \r\ <div>\r\ %s\r\ </div>\r\ \r\ </div><!-- /.container -->\r\ '% (len(the_images), update_time, HTML_LIST) return "%s%s%s%s"%(HTML_HEADER, html_navbar(self.view_days), HTML_BODY, HTML_FOOTER) if __name__ == '__main__': conf = { '/': { 'tools.sessions.on': True, 'tools.staticdir.root': os.path.abspath(myDir) }, '/assets': { 'tools.staticdir.on': True, 'tools.staticdir.dir': './assets' } } cherrypy.config.update( {'server.socket_host': '0.0.0.0'} ) if len(get_images("%s/assets/images/"% myDir)) == 0: print "No images...pulling all" download_email(myDir, 'ALL') cherrypy.quickstart(GrisVakt(), '/', conf)