-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
43 lines (31 loc) · 1018 Bytes
/
app.py
File metadata and controls
43 lines (31 loc) · 1018 Bytes
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
import os
import sys
import time
from multiprocessing import Process
from datetime import datetime
from flask import render_template
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '.'))
from auth import auth_bp
from admin import admin_bp, fetch_instances_cost_from_aws
from user_blueprint import user_bp
from settings import app, db
# Registaring blueprints
app.register_blueprint(auth_bp)
app.register_blueprint(admin_bp)
app.register_blueprint(user_bp)
@app.route('/')
def index():
return render_template('login.html')
def fetch_bill_from_aws(duration=86400):
while True:
fetch_instances_cost_from_aws()
delay = duration + int(time.time() / duration) * duration - time.time()
print("Going to sleep for %s seconds" % delay)
time.sleep(delay)
def bill_scheduler():
process = Process(target=fetch_bill_from_aws, args=(86400, ))
process.start()
bill_scheduler()
if __name__ == '__main__':
db.init_app(app)
app.run()