#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from flask import render_template, make_response
from flask_restx import Namespace, Resource, fields

from .data_access_object import TemplateObject as DAO

# defaults_folder = "defaults"

# api = Namespace('defaults', description='Defaults template parameters')

web = Namespace('templates', description='Defaults template parameters')

dao = DAO()

@web.route("/")
class TemplateList(Resource):

    def get(self):
        data = dao.todos
        return make_response(render_template("ob_controls.html", data=data))

@web.route("/<string:name>")
class Template(Resource):

    def get(self,name):
        data = dao.show(name)
        data["content"] = [data["content"]]
        return make_response(render_template("ob.html", data=data))
