Projekt

Obecné

Profil

Stáhnout (1.15 KB) Statistiky
| Větev: | Tag: | Revize:
1 6e333f54 Stanislav Král
from flask import Flask
2 62d64d21 Stanislav Král
import os
3 5b57121e Captain_Trojan
from src.controllers.certificates_controller import CertController
4 6e333f54 Stanislav Král
5
app = Flask(__name__)
6
7
8
@app.route('/')
9
def index():
10 750d8afa Stanislav Král
    return 'Welcome to the X.509 management application homepage!'
11 6e333f54 Stanislav Král
12
13 5b57121e Captain_Trojan
@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 fb987403 Captain_Trojan
@app.route('/api/certificates/<id>', methods=["GET"])
24
def get_cert(id):
25
    return CertController.get_certificate_by_id(id)
26
27
28 5b6d9513 Captain_Trojan
@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 d53c2fdc Captain_Trojan
@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 6e333f54 Stanislav Král
if __name__ == '__main__':
39 62d64d21 Stanislav Král
    host = "0.0.0.0"
40
    port = 5000
41
42 9832694f Stanislav Král
    # TODO better load this from config.py
43 62d64d21 Stanislav Král
    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 5b57121e Captain_Trojan
    app.run(host=host, port=port)