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
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn app:app
25 changes: 18 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import schedule
import time
import threading
from init_db import initializeDB


def get_db_connection():
Expand All @@ -18,7 +19,9 @@ def get_db_connection():
return conn


app = Flask(__name__)
app = Flask(__name__, template_folder='Templates')
app.config['SECRET_KEY'] = 'secret123'
# app.config['EXPLAIN_TEMPLATE_LOADING'] = True


@app.route('/')
Expand Down Expand Up @@ -181,6 +184,15 @@ def add_url():
return redirect(url_for('dashboard'))


# Unique Endpoint protected By Secret ID to clear the database completely
@app.route('/clearAll/<string:id>', methods=['GET'])
def clearDatabase(id):
print([id])
if [id] == ['secret@key@to@delete@database@entries']:
initializeDB()
return redirect(url_for('register'))


def checkFunction():
# get db conn
print("checkFunction Called")
Expand Down Expand Up @@ -214,7 +226,7 @@ def updateThread():
print("Update Thread Called")
print(threading.current_thread().name)
# schedule.every(1).minutes.do(checkFunction)
schedule.every(1).hours.do(checkFunction)
schedule.every(6).hours.do(checkFunction)
while True:
# print("While loop of updateThread")
schedule.run_pending()
Expand All @@ -233,11 +245,10 @@ def update():
return redirect(url_for("dashboard"))


if __name__ == "__main__":
@app.before_first_request
def thread_start():
threading.Thread(target=updateThread).start()
app.secret_key = 'secret123'

# For Production/Deployment
app.run()
# For Development
# app.run(debug=True)
if __name__ == '__main__':
app.run(debug=True, threaded=True, use_reloader=False)
Binary file modified database.db
Binary file not shown.
17 changes: 8 additions & 9 deletions init_db.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import sqlite3

connection = sqlite3.connect('database.db')


with open('schema.sql') as f:
connection.executescript(f.read())

cur = connection.cursor()
# will include querries to be run initially
connection.commit()
connection.close()
def initializeDB():
connection = sqlite3.connect('database.db')
with open('schema.sql') as f:
connection.executescript(f.read())
cur = connection.cursor()
# will include querries to be run initially
connection.commit()
connection.close()
Binary file added requirements.txt
Binary file not shown.