title: dynamically populate dropdown; passing "filename" to SimpleForm() Class
body: <p>I'm trying to dynamically populate a dropdown based upon column names in a csv that the user has uploaded.  After the user uploads the file (variable name is filename) and is redirected to the next page, /analysis/, how do I actually pass the filename to the SimpleForm(form) class to actually generate the dropdown list? 
  The code is question is </p>
  
  <pre><code>form = SimpleForm(filename)
  </code></pre>
  
  <p>I know that I can't pass filename directly to class SimpleForm(object) but how do I do it?</p>
  
  <pre><code>class MultiCheckboxField(SelectMultipleField):
  widget = widgets.ListWidget(prefix_label=False)
  option_widget = widgets.CheckboxInput()
  
  
  class SimpleForm(Form):
      list_of_files = ['Standard New/Renew/Upsell/Downsell/Churn Analysis', 'Top Ten Customer Accounts','Churn Analysis']
      # create a list of value/description tuples
      files = [(x, x) for x in list_of_files]
      test = pd.read_csv(filename, index_col = None, nrows = 0, header=0)
      second_list = list(test.columns)
      second_files = [(x, x) for x in second_list]
      acheckbox = MultiCheckboxField('Label', choices=files)
      bcheckbox = MultiCheckboxField('Label', choices=second_files)
      categories = SelectField('Label',choices = files)
  
  
  
  @app.route('/', methods=['GET', 'POST'])
      def index():
          if request.method == 'POST':
              file = request.files['file']
              if file and allowed_file(file.filename):
                  filename = secure_filename(file.filename)
                  file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))
                  if columns_len(filename):
                      title = filename.split('.')[0].title() #creates the title
                      return redirect(url_for('analysis', filename=filename))
                  else:
                      flash(u'Your CSV has less than three columns.  Please re-upload', 'error')
              else:
                  flash(u'Invalid file type.  Please re-upload', 'error')
          return render_template('index.html')
  
      @app.route('/analysis/&lt;filename&gt;', methods=['GET','POST'])
      def analysis(filename):
  
          form = SimpleForm(filename)
          return render_template('analysis.html', filename=filename, form=form)
  </code></pre>