1
|
from flask import Flask, redirect
|
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 redirect("/static/index.html")
|
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
|
@app.route('/api/certificates/<id>/chain', methods=["GET"])
|
39
|
def get_cert_chain(id):
|
40
|
return CertController.get_certificate_trust_chain_by_id(id)
|
41
|
|
42
|
|
43
|
if __name__ == '__main__':
|
44
|
host = "0.0.0.0"
|
45
|
port = 5000
|
46
|
|
47
|
# TODO better load this from config.py
|
48
|
if "FLASK_HOST" in os.environ:
|
49
|
host = os.environ["FLASK_HOST"]
|
50
|
|
51
|
if "FLASK_PORT" in os.environ:
|
52
|
host = os.environ["FLASK_PORT"]
|
53
|
|
54
|
app.run(host=host, port=port)
|