-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathserver.py
59 lines (46 loc) · 1.51 KB
/
server.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
import datetime
from flask_cors import CORS
from flask import Flask, render_template, request
from api.apiDocs import api_documentation
from api.pdamInquiries import pdamInquiriess
from api.prepaidInquiries import prepaidInquiriess
from api.postpaidInquiries import postpaidInquiriess
from api.bpjsInquiries import bpjsKesehatanInquiriess
app = Flask(__name__, template_folder='views')
# Init CORS
CORS(app, resources={r"/*": {"origins": "*"}})
# Init API Docs
api_documentation.init_app(app)
# Route Pdam Inquiries
app.register_blueprint(pdamInquiriess)
# Route Prepaid Inquiries
app.register_blueprint(prepaidInquiriess)
# Route Postpaid Inquiries
app.register_blueprint(postpaidInquiriess)
# Route BPJS Kesehatan Inquiries
app.register_blueprint(bpjsKesehatanInquiriess)
@app.route('/', methods=['GET'])
@app.route('/api', methods=['GET'])
@app.route('/api/', methods=['GET'])
def index():
return {
"status": True,
"message": "API Cek 📑🗓 is running",
"datetime": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
}, 200
@app.route('/apps', methods=['GET'])
def apps():
return render_template('index.html')
@app.errorhandler(404)
def not_found(e):
if request.path == '/':
return {
"status": True,
"message": "API Cek 📑🗓 is running",
"datetime": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
}, 200
else:
return {
"status": False,
"message": "API Path Not Found"
}, 404