-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
47 lines (39 loc) · 1.36 KB
/
app.py
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
from flask import Flask, render_template, session
from vehicle import Vehicle
from slots import slots
from owner import owner
from sensor import sensor
from bookingslot import booking
from payment import payment
from auth import auth, login_required
from bookingslot import clearExpiredBookings
from apscheduler.schedulers.background import BackgroundScheduler
import logging
from utils import requires_role
app = Flask(__name__)
app.secret_key = 'kjasdfhoiuehsfowe9phif9824ye8972hwuiefohnsdfp'
@login_required
@app.route('/')
def index():
return render_template("index.html")
app.register_blueprint(Vehicle)
app.register_blueprint(slots)
app.register_blueprint(owner)
app.register_blueprint(sensor)
app.register_blueprint(booking)
app.register_blueprint(payment)
app.register_blueprint(auth)
@app.context_processor
def inject_user():
username = session.get('username')
SNo = session.get('SNo')
return dict(username=username)
def configure_scheduler():
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
scheduler = BackgroundScheduler()
scheduler.add_job(func=clearExpiredBookings, trigger="interval", minutes=5)
scheduler.start()
logging.info("Scheduler started to clear expired bookings every 5 minutes.")
configure_scheduler()
if __name__ == '__main__':
app.run(debug=True, port='5000')