Import data


I build a web app with flask. Through a button the user gonna choose a csv file from a desktop and when he clicks to submit a config file gonna run to import that file (the user previously chosen) into ES. So I got a difficult to code that with flask, this is my try
1- This is the user interface: profile.html

{% extends "base.html" %}

{% block content %}
    <h1 class="title"> Welcome, {{ name }}! </h1>
    <h3>You can choose your file </h3>
    <form enctype="multipart/form-data" class="" action="data" method="post">
    	<input type="file" name="csvfile" value="">
    	<input type="submit" name="" value="submit">
{% endblock %}

2- This is a standard config file: file.config

      start_position => "beginning"
      sincedb_path => "NUL"
      codec => plain { charset => "CP1252" }
	csv {
        separator => ";"
        convert => {
            "longitude" => "float"
            "latitude" => "float"
    date { match => [ "time", "dd MMM yy HH:mm:ss" ] }

    mutate{ add_field => { "location" => "%{latitude},%{longitude}" } }

	elasticsearch { 
	    action => "index"
        hosts => ["http://localhost:9200/"] 

3- This is the data function :

from flask import Blueprint, render_template, request
import csv
from flask_login import login_required, current_user
from . import db

main = Blueprint('main', __name__)

def index():
    return render_template('index.html', methods=['GET', 'POST'])

def profile():
    return render_template('profile.html', 
**@main.route('/data', methods=['GET', 'POST'])**
**def data():**
**	if request.method == 'POST':**
**		f = request.files['csvfile']**

Could anyone tell me how I can implement that with flask please.

Please continue the discussion at Run Logstash config file from a web app