from datetime import datetime


apis_py = """from panther import __version__
from panther.app import API
from panther.request import Request
from panther.response import Response
from panther.configs import config


@API.get()
async def hello_world(request: Request):
    data = {
        'version': __version__ ,
        'debug': config['debug'],
        'db_engine': config['db_engine'],
        'default_cache_exp': config['default_cache_exp'],
        'authentication': config['authentication'],
    }
    return Response(data=data, status_code=200)

"""

models_py = """from panther.db import BaseModel

"""

serializers_py = """from pydantic import BaseModel

"""

app_urls_py = """from app.apis import hello_world

urls = {
    '': hello_world,
}

"""

configs_py = """\"""
{PROJECT_NAME} Project (Generated by Panther on %s)
\"""

from pathlib import Path
from dotenv import dotenv_values


DEBUG = True 
BASE_DIR = Path(__name__).resolve().parent
env = dotenv_values(BASE_DIR / '.env')

DB_NAME = env['DB_NAME']
SECRET_KEY = env['SECRET_KEY']


Middlewares = [
    ('panther.middlewares.db.Middleware', {'url': f'tinydb://{BASE_DIR}/{DB_NAME}.json'}),
]

URLs = 'core/urls.py'

""" % datetime.now().date().isoformat()

env = """
SECRET_KEY = 'THIS_IS_THE_SECRET_SECRET_KEY'

DB_NAME = '{PROJECT_NAME}'

"""

main_py = """from panther import Panther

app = Panther(__name__)

"""

urls_py = """from app.urls import urls as app_urls

urls = {
    '/': app_urls, 
}

"""

git_ignore = """__pycache__/
.venv/
.idea/
.env

"""

Template = {
    'app': {
        'apis.py': apis_py,
        'models.py': models_py,
        'serializers.py': serializers_py,
        'urls.py': app_urls_py,
    },
    'core': {
        'configs.py': configs_py,
        'urls.py': urls_py,
    },
    'main.py': main_py,
    '.env': env,
    '.gitignore': git_ignore,
}


# TODO: Add core/middlewares.py to Template
