tiangolo / full-stack

Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
MIT License
523 stars 81 forks source link

How to setup Flask-Admin #14

Closed michaeltoohig closed 4 years ago

michaeltoohig commented 5 years ago

I would like to add Flask-Admin to my backend. When trying to access the /admin endpoint I get a blank page but with the frontend stopped I get a 404.

To test I've added to app_setup.py the following below where sentry is initialized.

from flask_admin import Admin
admin = Admin(app, name=f"{config.PROJECT_NAME}", template_mode="bootstrap3")

I'm just kinda lost as to what needs to be changed. Any help is much appreciated.

michaeltoohig commented 5 years ago

I found a solution but not yet if its a complete solution.

Adding the following to backend -> labels in docker-compose.dev.labels.yml works.

- traefik.frontend.rule=PathPrefix:/admin

Edit This seems to overwrite the rule preceding it which was for /api. Edit 2 This issue addresses my question https://github.com/containous/traefik/issues/419 Just needed to comma separate the two endpoints.

- traefik.frontend.rule=PathPrefix:/admin, /api
tiangolo commented 5 years ago

Awesome! Thanks for sharing the solution.

michaeltoohig commented 5 years ago

I do have a question related to this. I have had a hard time trying to add rules that would make traefik bypass specific subdomains or paths to services not in this project/swarm. Is that even possible?

Thanks.

tiangolo commented 5 years ago

@michaeltoohig sorry for the delay, if I understand the problem, yes, you can have a global Traefik in the Docker Swarm cluster that handles several domains for several stacks.

And then, each stack will have its own domain(s), and its own internal (intra-stack) Traefik proxy.

The global Traefik can be set up following DockerSwarm.rocks

And the internal stacks can be generated with this project generator or all the "siblings".

For example, using the new FastAPI you could generate the projects with:

https://github.com/tiangolo/full-stack-fastapi-postgresql

https://github.com/tiangolo/full-stack-fastapi-couchbase

tiangolo commented 4 years ago

Hi @michaeltoohig , I'll assume you were able to solve your problem and I'll close this issue now.


If you are still using this project, I suggest you check the equivalent project generator for FastAPI that solves the same use cases in a much better way.

Because of that, this Flask-based project generator is now going to be deprecated. You are still free to use it, but it won't receive any new features, changes, or bug fixes.