from datetime import datetime


apis_py = """from panther.app import API


@API.get()
async def hello_world():
    return {'detail': 'hello world'}

"""

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 = """\"""
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.py', {'url': f'sqlite:///{BASE_DIR}/{DB_NAME}.db'}),
]

URLs = 'core/urls.py'
""" % datetime.now().date().isoformat()

middlewares_py = """from panther.middlewares import BaseMiddleware

"""

env = """
SECRET_KEY = 'THIS_IS_THE_SECRET_SECRET_KEY'

DB_NAME = 'panther'

"""

main_py = """import uvicorn
from panther import Panther

app = Panther(__name__)

if __name__ == '__main__':
    uvicorn.run('main:app')

"""

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

urls = {
    '': app_urls, 
}

"""

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