I am trying to delete files in flask after they are downloaded, but I'm hung up on file path issues, generating empty excel files. The file that is downloaded is passed to the route for the file download from a session variable. The following code finds the file and downloads it: @app.route('/dnld_outputfile/', methods=['POST','GET']) def download_output(): output_file1 = session.get('session_variable', None) return send_file(output_file1, attachment_filename='outputfile.xlsx', as_attachment=True) But this code uses a generator to serve and then delete the file: @app.route('/dnld_outputfile/', methods=['POST','GET']) def download_output(): output_file1 = session.get('output_file', None) path = os.path.join(current_app.instance_path,output_file1) def generate(): with open(path) as f: yield from f os.remove(output_file1) r = app.response_class(generate(), …

Member Avatar
+0 forum 0

Hello, I'm having trouble posting JSON to a url using Flask, AJAX and Javascript. Essentially, I would code using a library [Jquery Sortable](https://johnny.github.io/jquery-sortable/) to create a sorted list. From that sorted list I want to post to the server. The problem is that the server does not recieve the JSON post at all (or rather it doesn't know the content type). Now I've experimetned with multipe methods and it has led me to this issue of not posting. The information is posted below: {% extends "base.html" %} {%block title %}{{Title_Program}}{%endblock%} {% block styles %} {{super()}} <!-- In <head> --> <style …

Member Avatar
+0 forum 0

Hello, i have a sample web appliaction which get a value from HTML text feild and redirect to HTML page according to the value passed but the problem is that i can't get the value entered in the html text throught (request.form) method I get the below error werkzeug.routing.BuildError: Could not build url for endpoint 'suc'. Did you forget to specify values ['name']? from flask import Flask ,redirect, url_for, request app = Flask (__name__) @app.route('/suc/<name>') def suc(name): return "hello Boss %s" % name @app.route('/login', methods = ['GET','POST']) def login(): if request.method == 'post': user = request.form['nm'] return redirect(url_for('suc',name = user)) …

Member Avatar
Member Avatar
+0 forum 1

What I am trying to do is create a form that is automatically generated and then the values from that form are then used to proceed in the program. Currently to generate my form I am using this function `real_names=["Jason","Casandra"]` this portion of the code is not static it is generated with the names of the previous part of the form. form = """ <h2>What fields do you want your employee's on?:</h2> <dl> """ def form_creator(name): print name dt = "<dt>" dt_1 = dt+name.title()+":" dt_kill = "</dt>" input_basic_1 = '''<input name="''' input_basic_2 = """" size="1"> </input>""" generated_input = dt_1+ input_basic_1 …

Member Avatar
+0 forum 0

I am new to flask and new to git so hopefully someone can help me. This is my git repo: https://github.com/ccandillo/ma-inventory.git I am trying to create a web based spreadsheet. I am storing my data in a sqlite3 database. On my edit page, I would like to be able to edit existing entries and save them back to the database. But I don't know how to get the form data. I also, don't know how to interactively introspect/debug that edit page to see what exists in that namespace. I know you can use request.form.getitems('asset_tag') but it is not working for …

Member Avatar
+0 forum 0

The End.