"""

"""
import logging
import sys
from flask import Flask, Blueprint,render_template, send_from_directory,jsonify, url_for, abort
from flask_frozen import Freezer
from config import Config
import os
import re
from functools import partial
import yaml
import slugify


# Initialize application
app = Flask(__name__)
app.config["url_prefix"]=""
app.logger.setLevel(logging.DEBUG)
# Initialize FlatPages Index

lvas= [
    {"name": "LVA1"}
]

with open("data/test.yaml","r") as f:
    lvas=yaml.load(f.read(),yaml.Loader)
app.logger.info(lvas)
app.logger.info('Initialize FET BSP Sammlung')

freezer = Freezer(app)

page_blueprint  = Blueprint('bsp', __name__)
api_blueprint  = Blueprint('api', __name__)

@app.template_filter()
def slug(string):
    return slugify.slugify(string)

@app.template_filter()
def toyaml(obj):
    return yaml.dump(obj)


#@page_blueprint.route('/<path:name>/',strict_slashes=False)
@page_blueprint.route('/')
#@csp_header()
def index():
    return render_template("lva_liste.html", lvas=lvas)
       



@api_blueprint.route('/index.json',strict_slashes=False)
def api_index(name='index'):
    return jsonify(page={}), 200, {'Content-Type': 'application/json; charset=utf-8'}
    
    

    
app.register_blueprint(page_blueprint, url_prefix=app.config["url_prefix"],static_folder='static')
app.register_blueprint(api_blueprint, url_prefix=app.config["url_prefix"]+"/api/",static_folder='static')
#app.add_url_rule('%s/<path:name>' % cfg.url_prefix,'page', post)
