Hello the list (and hopefully Martin), I love mimerender and use it all over; thanks for writing it! I am trying to accommodate a flexible use case and wondered if anyone could help.
I have a GET request that can either provide a list of files or, if a specific file is specified, it will download the particular file. So the url would work like this: http://localhost/updown/ The HTML version is a table formatted list of files (name is sha1) with size and date uploaded, delete link per file (using JSON DELETE method) and an upload form (using POST). The second form of this data just is a JSON list with the file name size and date. http://localhost/updown/sha1hash... Specifying the file name (sha1 hash) will download the file itself, with appropriate content type/length headers and utilizing X-Sendfile for file delivery by the web server. Here is a simplified class set up: class index: @mimerender( default = 'html', override_input_key = 'format', html = render_html, json = render_json, ) def GET(self, get_string = ''): filename = get_string.lstrip('/') filepath = os.path.join( FILE_DIR, filename ) if SHA1_REGEX.match(filename): if not os.path.exists( filepath ): raise web.notfound() return wputil.download_file( filepath ) else: f = file_upload_form() return htmlout.main ( { 'status' : 'success', 'message' : 'A simple file uploader/ downloader.', 'files' : os.listdir( FILE_DIR ), 'form' : f } ) I already have a CustomEncoder to drop the webpy form for the json response, so that all works. I'm getting tripped up on how to return the file download without tripping over mimerender. Is there a way to return the file download with some kind of parameter to avoid being processed by mimerender? Right now I'm just returning HTML directly or the file download, but I'd like to be able to use the same URL for REST requests. Any ideas? Tony -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
