-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·33 lines (19 loc) · 917 Bytes
/
app.py
File metadata and controls
executable file
·33 lines (19 loc) · 917 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
from flask import Flask
from helpers.environment import Environment
import postgres_service_gateway.controllers as controllers;
class HttpServer(Flask):
def __init__(self, app_name:str):
super().__init__(app_name:str);
def handle_func(self, route:str, func:callable, methods:list = ['GET','POST']):
super().add_url_rule(route,view_func=func, methods=methods);
#check if the route have a foward slash
char = route[-1];
if(char != '/'):
route +='/'
super().add_url_rule(route,view_func=func, methods=methods);
app = HttpServer(__name__)
app.handle_func("/",controllers.IndexController);
app.handle_func("/api/v{0}/dataaccess/proc".format(controllers.VERSION), controllers.ProcedureController, methods=['POST'])
if __name__ =="__main__":
port = Environment.get("PORT", 8080)
app.run(port=port)