# Path: app/routes.py
# def index() -> Any:
# def resume() -> Any:
# def projects() -> Any:
# def notes() -> Any:
# def shelf() -> Any:
# def note(slug: str = '') -> Any:
# def references() -> Any:
# def reference(slug: str = '') -> Any:
# def about() -> Any:
# def atom_feed() -> Any:
# def sitemap_urls() -> Any:


import os
import dotenv
    import rollbar
    import rollbar.contrib.flask
from typing import Any, Dict
from flask import (
    Flask,
    Response,
    got_request_exception,
    render_template,
)
from flask_sitemap import Sitemap
from syspath import git_root
from varsnap import varsnap
from app.routes import handlers, sitemap_urls  # noqa: E402
ext = Sitemap(app=app)
ext.register_generator(sitemap_urls)


if os.environ['ENV'] == 'production':

    @app.before_first_request
    def init_rollbar() -> None:
        """init rollbar module"""
        rollbar.init(
            os.environ['ROLLBAR_SERVER_TOKEN'],
            # environment name
            os.environ['ENV'],
            # server root directory, makes tracebacks prettier
            root=os.path.dirname(os.path.realpath(__file__)),
            # flask already sets up logging
            allow_logging_basic_config=False)

        # send exceptions from `app` to rollbar, using flask's signal system.
        got_request_exception.connect(
            rollbar.contrib.flask.report_exception, app)


@app.context_processor
def inject_envs() -> Dict[str, Any]:
    envs = {}
    envs['SEGMENT_TOKEN'] = os.environ['SEGMENT_TOKEN']
    return {'ENV': envs}



# Path: app/routes.py
# def index() -> Any:
# def resume() -> Any:
# def projects() -> Any:
# def notes() -> Any:
# def shelf() -> Any:
# def note(slug: str = '') -> Any:
# def references() -> Any:
# def reference(slug: str = '') -> Any:
# def about() -> Any:
# def atom_feed() -> Any:
# def sitemap_urls() -> Any:


# Path: app/serve.py
import os
import dotenv
    import rollbar
    import rollbar.contrib.flask
from typing import Any, Dict
from flask import (
    Flask,
    Response,
    got_request_exception,
    render_template,
)
from flask_sitemap import Sitemap
from syspath import git_root
from varsnap import varsnap
from app.routes import handlers, sitemap_urls  # noqa: E402

ext = Sitemap(app=app)
ext.register_generator(sitemap_urls)


if os.environ['ENV'] == 'production':

    @app.before_first_request
    def init_rollbar() -> None:
        """init rollbar module"""
        rollbar.init(
            os.environ['ROLLBAR_SERVER_TOKEN'],
            # environment name
            os.environ['ENV'],
            # server root directory, makes tracebacks prettier
            root=os.path.dirname(os.path.realpath(__file__)),
            # flask already sets up logging
            allow_logging_basic_config=False)

        # send exceptions from `app` to rollbar, using flask's signal system.
        got_request_exception.connect(
            rollbar.contrib.flask.report_exception, app)


@app.context_processor
def inject_envs() -> Dict[str, Any]:
    envs = {}
    envs['SEGMENT_TOKEN'] = os.environ['SEGMENT_TOKEN']
    return {'ENV': envs}



app.register_blueprint(handlers)