def get(self): #master_image = db.get(self.request.get("img_id")) master_image = open("img.jpg").read() # Create block for all items in DB blocks = [ ImageBlock(img.data) for img in ImageModel.all() ] mosaic = Mosaic(master_image, blocks) image_out = mosaic.get_image() self.response.headers['Content-Type'] = "image/png" self.response.out.write(image_out)
def get(self): """ Called for HTTP get on /(when ever page / is requested). Presents a list of subscriptions for this week. The data presented is essentially read only of not logged in or read/write if logged in. All HTML rendering is handled by the viernes_util module. Two strings are formatted: the body and the title, these are passed to viernes_util.page which produced the complete page html. """ #create a new page and set the title html_page = util.html_page() html_page.set_title("Photo montage") form_inputs = list() form_inputs.append(html_page.form_input('img',"file",'Add Image')) html_page.append_top( html_page.form("Add Image",'/image/add',form_inputs)) html_page.append_top( html_page.form_get("Create Mosaic",'/mosaic/create')) html_page.append_content(html_page.img('/images/selected_img', 'main image', 'selected image')) html_page.append_content(html_page.img('/images/mosaic_img', 'mosaic image', 'mosaic image')) siteimgs_query = ImageModel.all() imgs_html_string = "" for siteimg in siteimgs_query : imgs_html_string += siteimg.to_html(html_page, "image/set_as_default") html_page.append_footer(html_page.div(imgs_html_string, 'site_images')) #Render it html_page.page(self)