1
|
from flask import Flask
|
2
|
import os
|
3
|
from src.controllers.certificates_controller import CertController
|
4
|
|
5
|
app = Flask(__name__)
|
6
|
|
7
|
|
8
|
@app.route('/')
|
9
|
def index():
|
10
|
return 'Welcome to the X.509 management application homepage!'
|
11
|
|
12
|
|
13
|
@app.route('/api/certificates', methods=["POST"])
|
14
|
def create_certificate():
|
15
|
return CertController.create_certificate()
|
16
|
|
17
|
|
18
|
@app.route('/api/certificates', methods=["GET"])
|
19
|
def get_cert_list():
|
20
|
return CertController.get_certificate_list()
|
21
|
|
22
|
|
23
|
@app.route('/api/certificates/<id>', methods=["GET"])
|
24
|
def get_cert(id):
|
25
|
return CertController.get_certificate_by_id(id)
|
26
|
|
27
|
|
28
|
@app.route('/api/certificates/<id>/details', methods=["GET"])
|
29
|
def get_cert_detes(id):
|
30
|
return CertController.get_certificate_details_by_id(id)
|
31
|
|
32
|
|
33
|
@app.route('/api/certificates/<id>/root', methods=["GET"])
|
34
|
def get_cert_root(id):
|
35
|
return CertController.get_certificate_root_by_id(id)
|
36
|
|
37
|
|
38
|
if __name__ == '__main__':
|
39
|
host = "0.0.0.0"
|
40
|
port = 5000
|
41
|
|
42
|
# TODO better load this from config.py
|
43
|
if "FLASK_HOST" in os.environ:
|
44
|
host = os.environ["FLASK_HOST"]
|
45
|
|
46
|
if "FLASK_PORT" in os.environ:
|
47
|
host = os.environ["FLASK_PORT"]
|
48
|
|
49
|
app.run(host=host, port=port)
|