def download_sample(name): a, b = name.split('.') f = StringIO.StringIO(sample.export(a, b)) f.seek(0) return send_file(f, attachment_filename=name + '.json', as_attachment=True, add_etags=False)
def ModularForm_GSp4_Q_top_level(page=None): if request.args.get('empty_cache') or not COLNS: # we trigger a (re)scan for available collections rescan_collection() bread = [("Modular Forms", url_for('mf.modular_form_main_page')), ('Siegel modular forms', url_for('ModularForm_GSp4_Q_top_level'))] # info = dict(args); info['args'] = request.args #info['learnmore'] = [] # parse the request if not page: name = request.args.get('download') if name: a, b = name.split('.') f = StringIO.StringIO(sample.export(a, b)) # print f.getvalue() f.seek(0) return send_file(f, attachment_filename=name + '.json', as_attachment=True) else: return prepare_main_page(bread) if page in COLNS: return prepare_collection_page(COLNS[page], request.args, bread) if 'dimensions' == page: return prepare_dimension_page(request.args, bread) if 'search_results' == page: return prepare_search_results_page(request.args, bread) # check whether there is a sample called page try: a, b = page.split('.') except: a = b = None sam = sample.Samples({'collection': a, 'name': b}) if len(sam) > 0: return prepare_sample_page(sam[0], request.args, bread) # return an error: better emit a 500 info = {'error': 'Requested page does not exist'} return render_template("None.html", **info)
def ModularForm_GSp4_Q_top_level( page = None): if request.args.get('empty_cache') or not COLNS: # we trigger a (re)scan for available collections rescan_collection() bread = [("Modular Forms", url_for('mf.modular_form_main_page')), ('Siegel modular forms', url_for('ModularForm_GSp4_Q_top_level'))] # info = dict(args); info['args'] = request.args #info['learnmore'] = [] # parse the request if not page: name = request.args.get( 'download') if name: a,b = name.split('.') f = StringIO.StringIO( sample.export( a, b)) print f.getvalue() f.seek(0) return send_file( f, attachment_filename = name + '.json', as_attachment = True) else: return prepare_main_page( bread) if page in COLNS: return prepare_collection_page( COLNS[page], request.args, bread) if 'dimensions' == page: return prepare_dimension_page( request.args, bread) if 'search_results' == page: return prepare_search_results_page( request.args, bread) # check whether there is a sample called page try: a,b=page.split('.') except: a=b=None sam = sample.Samples( { 'collection': a, 'name': b}) if len( sam) > 0: return prepare_sample_page( sam[0], request.args, bread) # return an error: better emit a 500 info = { 'error': 'Requested page does not exist' } return render_template("None.html", **info)
def download_sample(name): a,b = name.split('.') f = StringIO.StringIO(sample.export(a, b)) f.seek(0) return send_file(f, attachment_filename = name + '.json', as_attachment = True)