Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
41 changed files
with
614 additions
and
171 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
from geopy.geocoders import Nominatim | ||
from geopy.geocoders import Nominatim # Imports nominatim API | ||
import sqlite3 as sql | ||
import json, os, time | ||
|
||
|
||
database_locations = 'app/databases/locations.db' | ||
|
||
def getMsg(msg): | ||
con = sql.connect(database_locations) | ||
con = sql.connect(database_locations) # connecys to db, amkes cursor | ||
cur = con.cursor() | ||
geolocator = Nominatim(user_agent="Web_app") | ||
try: | ||
geolocator = Nominatim(user_agent="Web_app") # starts nominatim | ||
try: # Tries SQL to create table | ||
cur.execute("CREATE TABLE Location(tid VARCHAR2(2), longitude NUMBER(10,6), latitude NUMBER(10,6), city VARCHAR2(20), road VARCHAR2(30), date VARCHAR2(20), time VARCHAR2(20), tst INT(15));") | ||
except: | ||
pass | ||
data = json.loads(msg.payload.decode("utf8")) | ||
data = json.loads(msg.payload.decode("utf8")) | ||
tid = data["tid"] | ||
lat = data["lat"] | ||
lon = data["lon"] | ||
location = geolocator.reverse(f"{data['lat']},{data['lon']}") | ||
city = location.raw["address"]["city"] | ||
city = location.raw["address"]["city"] # Puts data into small array to be used later | ||
road = location.raw["address"]["road"] | ||
tst = data["tst"] | ||
_time = time.strftime('%H:%M:%S', time.localtime(tst)) | ||
_time = time.strftime('%H:%M:%S', time.localtime(tst))#sets time format | ||
_date = time.strftime('%d-%m-%Y', time.localtime(tst)) | ||
com = f"INSERT INTO Location values('{tid}','{lon}','{lat}','{city}','{road}','{_date}','{_time}','{tst}');" | ||
print(com) | ||
cur.execute(com) | ||
|
||
con.commit() | ||
con.commit() # commits changes to db | ||
cur.close() | ||
con.close() | ||
con.close()# # closes connection | ||
|
This file contains 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 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,10 @@ | ||
from flask import Blueprint, render_template, request, url_for, escape, redirect, session | ||
from app.functions.data_tools import data_getter | ||
|
||
average_bl = Blueprint('average', __name__) | ||
|
||
|
||
@average_bl.route("/", methods = ["GET"]) | ||
def index(): | ||
return render_template("average/index.html", | ||
locations = data_getter.get_locations_for(session['username'])) |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 flask import Blueprint, render_template, request, url_for, escape, redirect, session | ||
from app.functions.data_tools import data_getter | ||
|
||
picture_bl = Blueprint('picture', __name__) | ||
|
||
|
||
@picture_bl.route("/", methods = ["GET"]) | ||
def index(): | ||
return render_template("picture/index.html", | ||
user = session['username']) | ||
|
This file contains 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
Empty file.
This file contains 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 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
Oops, something went wrong.