# Run config file from a web app

**URL:** <https://discuss.elastic.co/t/run-config-file-from-a-web-app/230199>\
**Category:** Elasticsearch\
**Created:** [April 28, 2020, 2:40pm UTC](https://discuss.elastic.co/t/run-config-file-from-a-web-app/230199 "2020-04-28T14:40:45Z")\
**Posts on this page:** 3\
**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:40pm UTC](https://discuss.elastic.co/t/run-config-file-from-a-web-app/230199/1 "2020-04-28T14:40:45Z")

</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 what I'm trying to do :

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:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 29, 2020, 12:47am UTC](https://discuss.elastic.co/t/run-config-file-from-a-web-app/230199/2 "2020-04-29T00:47:35Z")

</div>

Please don't post the same thing more than once, it makes it harder for people to help you.

> [@Run config file from a web app (flask)](https://discuss.elastic.co/t/run-config-file-from-a-web-app-flask/230197):
>
> 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 input{ file{ path =\> 'new\_path' #Here it should be a dyn…

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 29, 2020, 12:47am UTC](https://discuss.elastic.co/t/run-config-file-from-a-web-app/230199/3 "2020-04-29T00:47:38Z")

</div>


