diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..c84bae6
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,2 @@
+.git
+Dockerfile
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..9db9ba8
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,11 @@
+FROM python:3.7-buster
+
+ENV APP_HOME /home
+WORKDIR $APP_HOME
+COPY . .
+
+RUN pip install -r requirements.txt \
+ && pip install flask \
+ && pip install werkzeug
+
+CMD python web.py
\ No newline at end of file
diff --git a/README.md b/README.md
index 48ba805..23265de 100644
--- a/README.md
+++ b/README.md
@@ -6,22 +6,37 @@ This is a script that generates an interactive geo heatmap from your Google loca
## Getting Started
-### 1. Install Python 3+
+### Using docker web-server
+```shell
+docker build -t geo_heatmap_web .
+docker run -d -p 80:80 geo_heatmap_web
+```
+
+`build` command creates a docker `image` from the `Dockerfile` and saves it with name pointed by paramter `-t`.
+
+`run` command create a new instance of the previews created image and starts it. `-p` parameter is used to public and map
+the host ports with the container ports.
+
+Now open browser on `http://localhost`
+___
+### Run the script natively
+
+#### 1. Install Python 3+
If you don't already have Python 3+ installed, grab it from . You'll want to download install the latest version of **Python 3.x**. As of 2019-11-22, that is Version 3.8.
-### 2. Get Your Location Data
+#### 2. Get Your Location Data
Here you can find out how to download your Google data:
Here you can download all of the data that Google has stored on you:
To use this script, you only need to select and download your "Location History", which Google will provide to you as a JSON file by default. KML is also an output option and is accepted for this program.
-### 3. Clone This Repository
+#### 3. Clone This Repository
On , click the green "Clone or Download" button at the top right of the page. If you want to get started with this script more quickly, click the "Download ZIP" button, and extract the ZIP somewhere on your computer.
-### 4. Install Dependencies
+#### 4. Install Dependencies
In a [command prompt or Terminal window](https://tutorial.djangogirls.org/en/intro_to_command_line/#what-is-the-command-line), [navigate to the directory](https://tutorial.djangogirls.org/en/intro_to_command_line/#change-current-directory) containing this repository's files. Then, type the following, and press enter:
@@ -29,7 +44,7 @@ In a [command prompt or Terminal window](https://tutorial.djangogirls.org/en/int
pip install -r requirements.txt
```
-### 5. Run the Script
+#### 5. Run the Script
In the same command prompt or Terminal window, type the following, and press enter:
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..6fb8ad2
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,8 @@
+
+Geo Heatmap Generator
+Geo Heatmap Generator
+Upload zip file from Google Maps History
+
diff --git a/web.py b/web.py
new file mode 100644
index 0000000..efc6311
--- /dev/null
+++ b/web.py
@@ -0,0 +1,50 @@
+import os
+from flask import Flask, flash, request, redirect, url_for, send_from_directory, current_app, render_template
+from werkzeug.utils import secure_filename
+from geo_heatmap import Generator
+
+UPLOAD_FOLDER = '/home/'
+ALLOWED_EXTENSIONS = {'zip', 'json', 'kml'}
+
+app = Flask(__name__)
+app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
+
+def allowed_file(filename):
+ return '.' in filename and \
+ filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
+
+@app.route('/uploads/')
+def download(filename):
+ uploads = os.path.join(current_app.root_path, '')
+ return send_from_directory(directory=uploads, filename=filename, as_attachment=True)
+
+@app.route('/', methods=['GET', 'POST'])
+def upload_file():
+ if request.method == 'POST':
+ # check if the post request has the file part
+ if 'file' not in request.files:
+ flash('No file part')
+ return redirect(request.url)
+ file = request.files['file']
+ # if user does not select file, browser also
+ # submit an empty part without filename
+ if file.filename == '':
+ flash('No selected file')
+ return redirect(request.url)
+ if file and allowed_file(file.filename):
+ filename = secure_filename(file.filename)
+ path_save = os.path.join(app.config['UPLOAD_FOLDER'], filename)
+ path_out = os.path.join(app.config['UPLOAD_FOLDER'], os.path.splitext(filename)[0]+'.html')
+ file.save(path_save)
+
+ generator = Generator()
+ generator.run([filename], path_out, [None, None], True, 'OpenStreetMap')
+
+ os.remove(path_save)
+
+ return redirect(url_for('download',
+ filename=path_out.split('/')[-1]))
+ return render_template('index.html')
+
+if __name__ == "__main__":
+ app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 80)))
\ No newline at end of file