-
Notifications
You must be signed in to change notification settings - Fork 228
add docker web server #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cTatu
wants to merge
7
commits into
luka1199:master
Choose a base branch
from
cTatu:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .git | ||
| Dockerfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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))) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.