from flask import Blueprint, redirect, url_for, send_file

from PandaCore import app

releases_blueprint = Blueprint('releases', __name__, url_prefix='/releases')
series_blueprint = Blueprint('series', __name__, url_prefix='/series')
resources_blueprint = Blueprint('resources', __name__, url_prefix='/resources')
files_blueprint = Blueprint('files', __name__, url_prefix='/files')
web_blueprint = Blueprint('web', __name__, url_prefix='/static')
tasks_blueprint = Blueprint('tasks', __name__, url_prefix='/tasks')

blueprints = (
    releases_blueprint,
    series_blueprint,
    resources_blueprint,
    files_blueprint,
    web_blueprint,
    tasks_blueprint,
)

# Must import all before registering blueprints
from . import (
    exception_handlers,
    releases,
    series,
    resources,
    files,
    web,
    tasks,
)

for blueprint in blueprints:
    app.register_blueprint(blueprint)


@app.route('/')
def root():
    return redirect(url_for('web.root'))
