# Run config file from a web app (flask)

**URL:** <https://discuss.elastic.co/t/run-config-file-from-a-web-app-flask/230197>\
**Category:** Logstash\
**Created:** [April 28, 2020, 2:36pm UTC](https://discuss.elastic.co/t/run-config-file-from-a-web-app-flask/230197 "2020-04-28T14:36:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![inchirah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inchirah/32/48145_2.png) [@inchirah](https://discuss.elastic.co/u/inchirah)\
**Post date:** [April 28, 2020, 2:36pm UTC](https://discuss.elastic.co/t/run-config-file-from-a-web-app-flask/230197/1 "2020-04-28T14:36:18Z")

</div>

Hello,

I build a web app with flask. Through a button the user gonna choose a csv file from his desktop and when he clicks to submit a LOGSTASH config file gonna run to import that file (the user previously chosen) into ELASTICSEARCH. So I got a difficulty to code that with flask, precisely how the config file takes the path of the csv file like an input? and how i be able to run the config file?

This is my try:

1- file.conf

```auto
input{
	file{
	    path => 'new_path' #Here it should be a dynamic variable 'new_path'
                               #and it should take the path of the csv file like
                              # an input ???
      start_position => "beginning"
      sincedb_path => "NUL"
      codec => plain { charset => "CP1252" }
	}
}
filter{
	csv {
        separator => ";"
        
          
        convert => {
            "longitude" => "float"
            "latitude" => "float"    
        } 
        
    }
    date { match => ["time", "dd MMM yy HH:mm:ss"] }

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

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

```

2- profile.html

```auto
{% extends "base.html" %}strong text
{% block content %}
    <h1 class="title"> Welcome, {{ name }}! </h1>
    <h3>You can import your data here </h3>
    <form enctype="multipart/form-data" class="" action="data" method="post">
    	<input type="file" name="csvfilename" value="">
    	<input type="submit" name="" value="submit">
    </form>
{% endblock %}

```

3- main.py

```auto
#That is the function that is responsible for the import of data into ES:  
@main.route('/data', methods=['GET', 'POST'])
def data():
	if request.method == 'POST':
		# Here I want to take the path of the file 
		new_path = os.path.abspath('csvfilename')
		# Here I should run the conf file ???
		 main.config.from_object('file', 'new_path')
	return render_template('data.html')

```

I will be grateful if anyone could help me. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 26, 2020, 2:36pm UTC](https://discuss.elastic.co/t/run-config-file-from-a-web-app-flask/230197/2 "2020-05-26T14:36:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
