-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
51 lines (38 loc) · 1.36 KB
/
__init__.py
File metadata and controls
51 lines (38 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import logging
from flask import Flask
from flask_apscheduler import APScheduler
import sqlite3
#app = Flask(__name__, static_folder="../frontend/build/", static_url_path="/")
app = Flask(__name__, static_folder="../frontend/dist/", static_url_path="/")
app.logger.setLevel(logging.INFO)
class Config:
SCHEDULER_API_ENABLED = True
app.config.from_object(Config())
# initialize scheduler
scheduler = APScheduler()
# if you don't wanna use a config, you can set options here:
# scheduler.api_enabled = True
scheduler.init_app(app)
scheduler.start()
@scheduler.task('interval', id='do_job_1', seconds=5, misfire_grace_time=900)
def job1():
con = sqlite3.connect("./HD/analysis.db")
data = con.execute("SELECT * FROM data").fetchall()
print(data[0][0])
KML = "<?xml version='1.0' encoding='UTF-8'?>\n<kml xmlns='http://www.opengis.net/kml/2.2'>\n<Document>"
# The row[2] and [1] are not an error. This is due to a flaw making the db
for row in data:
kml = (
"<Placemark>\n"
"<name>"+ row[0]+"</name>\n"
"<Point>\n"
"<coordinates>"+ row[2] +","+ row[1] +",0</coordinates>\n"
"</Point>\n"
"</Placemark>\n"
)
KML += kml
KML += "</Document></kml>"
file = open("./HD/data.kml", "w")
file.write(KML)
file.close()
from .routes import *