-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·72 lines (54 loc) · 2.15 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#FastAPI Package
from fastapi import FastAPI, Request,status
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from typing import Union
#uvicorn package
import uvicorn
#import Class Models from Models.py
from Models import Models
# from Procedure import Procedure
#created object from class model
objModel = Models()
def create_app():
app = FastAPI()
# set schedule setiap 6 jam
thread = Timer(config.KRB_LOOP_DELAY, kinit, ())
# thread = Timer(300, kinit, ())
thread.daemon = True
thread.start()
return app
#FastAPI Object
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
@app.get("/Rekening_Koran/casa/{no_rekening}/{start_date}/{end_date}")
async def read_no_rek(no_rekening: str, start_date, end_date: str):
##1.MUTASI
Mutasi = objModel.Mutasi(no_rekening,start_date,end_date,'casa')
##2.DEMOGRAFI
Demografi = objModel.demografi(no_rekening,start_date,end_date)
Footer = objModel.Footer()
##3.OUTPUT RESPONSE
Output = objModel.outputView(Mutasi,Demografi,Footer)
# Response = objModel.outputView(Mutasi)
return Output
# return templates.TemplateResponse(
# "item.html", {"request": request,
# "Demografi" : Demografi ,
# "Mutasi" : Mutasi}
# )
@app.get("/Rekening_Koran/loan/{no_rekening}/{start_date}/{end_date}")
async def read_no_rek(no_rekening: str, start_date, end_date: str):
#1. DEMOGRAFI
loanDemografi = objModel.loanDemografi(no_rekening,start_date,end_date)
mutasiLoan = objModel.Mutasi(no_rekening,start_date,end_date,'loan')
Footer = objModel.Footer()
#3. OUTPUT
Output = objModel.outputView(mutasiLoan,loanDemografi, Footer)
return Output
@app.get("/testing/{no_rekening}/{start_date}/{end_date}")
async def main_testing(no_rekening: str, start_date:str, end_date: str ):
result = objModel.testing(no_rekening,start_date,end_date)
return result