Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

admin app not loading properly #46

Closed
aminalaee opened this issue May 4, 2021 · 5 comments
Closed

admin app not loading properly #46

aminalaee opened this issue May 4, 2021 · 5 comments

Comments

@aminalaee
Copy link

When using the sample code, /admin returns 404.

Here's my main.py:

from fastapi import FastAPI
from fastapi_admin.factory import app as admin_app
from fastapi_admin.site import Site
from starlette.middleware.cors import CORSMiddleware
from tortoise.contrib.fastapi import register_tortoise

app = FastAPI()


@app.get("/")
async def root():
    return {"message": "Hello World"}

app.add_middleware(
        CORSMiddleware,
        allow_origins=["*"],
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
        expose_headers=["*"],
    )
register_tortoise(
    app,
    db_url="sqlite://:memory:",
    modules={"models": ["database.models"]},
    generate_schemas=True,
    add_exception_handlers=True,
)

app.mount("/admin", admin_app)

@app.on_event('startup')
async def startup():
    await admin_app.init(
        admin_secret="test",
        site=Site(
            name="FastAPI-Admin DEMO",
            login_footer="FASTAPI ADMIN - FastAPI Admin Dashboard",
            login_description="FastAPI Admin Dashboard",
            locale="en-US",
            locale_switcher=True,
            theme_switcher=True,
        ),
    )

Here's my requirements.txt:

aiomysql==0.0.21
aiosqlite==0.16.0
asyncpg==0.22.0
bcrypt==3.2.0
cffi==1.14.5
click==7.1.2
colorama==0.4.4
fastapi==0.63.0
fastapi-admin==0.3.3
gunicorn==20.1.0
h11==0.12.0
iso8601==0.1.14
Jinja2==2.11.3
MarkupSafe==1.1.1
passlib==1.7.4
prompt-toolkit==3.0.18
pycparser==2.20
pydantic==1.8.1
PyJWT==2.1.0
PyMySQL==0.9.3
pypika-tortoise==0.1.0
python-dotenv==0.17.1
python-rapidjson==1.0
pytz==2020.5
six==1.15.0
starlette==0.13.6
tortoise-orm==0.17.2
typing-extensions==3.10.0.0
uvicorn==0.13.4
wcwidth==0.2.5
XlsxWriter==1.4.0

@long2ice
Copy link
Collaborator

long2ice commented May 5, 2021

You are using old version, which will not maintain, you can try latest

@aminalaee
Copy link
Author

I've tried latest from dev branch but still /admin returns Not Found.

@kolinkovlad
Copy link

Experienced the same problem on the latest version.

@long2ice
Copy link
Collaborator

long2ice commented May 5, 2021

See README run local examples

@aminalaee
Copy link
Author

Very responsive and productive answers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants