from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel
from settings import config
#from parameciofast.fastadmin import admin_app
from importlib import import_module

app=FastAPI()

# apps={'admin': ['paramecio2.modules.admin', 'admin_app']}


for name_app, module_app in config.apps.items():
    controller_path=import_module(module_app[0])
    media_path=controller_path.__file__.replace('__init__.py', 'media')
    #print(media_path)
    app.mount("/mediafrom/"+name_app, StaticFiles(directory=media_path), name="static_"+name_app)
    
    fast_app=getattr(controller_path, module_app[1])
    
    app.mount("/"+name_app, fast_app)

# http://localhost:8000/mediafrom/admin/css/font-awesome.min.css

#app.mount("/mediafrom/admin", StaticFiles(directory="parameciofast/fastadmin/media"), name="static_admin")

#app.mount("/admin", admin_app)
