ETC
parent
3cb2708704
commit
3164963f9b
Binary file not shown.
19
app/keep.py
19
app/keep.py
|
|
@ -1,5 +1,6 @@
|
|||
from flask import Blueprint, render_template, request, g, url_for, redirect
|
||||
from datetime import datetime, date
|
||||
from pytz import timezone, utc
|
||||
import sqlite3
|
||||
|
||||
|
||||
|
|
@ -11,6 +12,9 @@ def get_db():
|
|||
db = g._database = sqlite3.connect("app/db/keepalive.db")
|
||||
return db
|
||||
|
||||
|
||||
|
||||
|
||||
@keep.route('/keepalive/')
|
||||
def dispkeepalive():
|
||||
conn = get_db()
|
||||
|
|
@ -33,7 +37,10 @@ def dispkeepalive():
|
|||
items.append(item)
|
||||
|
||||
return render_template("keepaliveshowpage.html", items=items)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@keep.route('/loc/<location>/', methods=["POST"])
|
||||
def getalive(location):
|
||||
|
|
@ -44,17 +51,21 @@ def getalive(location):
|
|||
location TEXT,
|
||||
date TEXT,
|
||||
time TEXT)""")
|
||||
|
||||
# Get actual system-local time (assumed to be in ET)
|
||||
now = datetime.now()
|
||||
|
||||
c.execute("""INSERT INTO keepalive2 (location, date, time)
|
||||
VALUES (?, ?, ?)""",
|
||||
(location,
|
||||
date.today().strftime("%m/%d/%y"),
|
||||
datetime.now().strftime("%H:%M:%S")))
|
||||
now.strftime("%m/%d/%y"),
|
||||
now.strftime("%H:%M:%S")))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
# Redirect to the same route with GET method
|
||||
return f"Keepalive recorded for {location}"
|
||||
|
||||
|
||||
@keep.route('/loc/<location>/', methods=["GET"])
|
||||
def show_location(location):
|
||||
return f"<h1>Received keepalive from: {location}</h1>"
|
||||
|
|
|
|||
Loading…
Reference in New Issue