Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
Dockerfile
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,45 @@ 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 <https://www.python.org/downloads/>. 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: <https://support.google.com/accounts/answer/3024190?hl=en></br>
Here you can download all of the data that Google has stored on you: <https://takeout.google.com/>

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 <https://github.com/luka1199/geo-heatmap>, 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:

```shell
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:

Expand Down
8 changes: 8 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!doctype html>
<title>Geo Heatmap Generator</title>
<h1>Geo Heatmap Generator</h1>
<h2>Upload zip file from Google Maps History</h2>
<form method=post enctype=multipart/form-data>
<input type=file name=file>
<input type=submit value=Upload>
</form>
50 changes: 50 additions & 0 deletions web.py
Original file line number Diff line number Diff line change
@@ -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/<filename>')
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)))