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

It works only with internet #307

Open
ronvaleron opened this issue May 6, 2024 · 6 comments
Open

It works only with internet #307

ronvaleron opened this issue May 6, 2024 · 6 comments

Comments

@ronvaleron
Copy link

Why did this framework is working only with internet?
I mean, it is not in local network without internet...

@ronvaleron ronvaleron changed the title It work only with internet It works only with internet May 6, 2024
@jimkring
Copy link
Contributor

jimkring commented May 6, 2024

It should be possible to get it to work locally, too. I agree with you. I just set up a local development environment for testing some TypeScript changes and was able to get it to work, but I had to tweak some things.

@jimkring
Copy link
Contributor

jimkring commented May 6, 2024

You could probably do the following:

  1. download the js and css files locally:

Stick them in a folder under your fastapi/flask project, inside a static/assets folder.

Then configure fastapi and fastui as follows:

import fastapi
import fastui

app = FastAPI()

# make sure you have a folder named 'static' in your project and put the css and js files inside a subfolder called 'assets'
app.mount("/static", StaticFiles(directory="static"), name="static")

# configure fastui to use these local css and js files instead of the ones on the CDN
fastui._PREBUILT_CDN_URL = f'/static/assets'

...

@ronvaleron
Copy link
Author

You could probably do the following:

  1. download the js and css files locally:

Stick them in a folder under your fastapi/flask project, inside a static/assets folder.

Then configure fastapi and fastui as follows:

import fastapi
import fastui

app = FastAPI()

# make sure you have a folder named 'static' in your project and put the css and js files inside a subfolder called 'assets'
app.mount("/static", StaticFiles(directory="static"), name="static")

# configure fastui to use these local css and js files instead of the ones on the CDN
fastui._PREBUILT_CDN_URL = f'/static/assets'

...

Yes, it works! Thank you very much.))
Just missed one import - from fastapi.staticfiles import StaticFiles

@jimkring
Copy link
Contributor

jimkring commented May 6, 2024

@ronvaleron Great! Thanks for the note about importing StaticFiles :)

@simonryf
Copy link

simonryf commented May 17, 2024

just adding that you probably also need the other files (CodeLazy.js, Markdown...)?

FASTUI_ASSETS_VERSION=0.0.23
FASTUI_ASSETS_URL=https://cdn.jsdelivr.net/npm/@pydantic/fastui-prebuilt@$FASTUI_ASSETS_VERSION/dist/assets/
wget -r -np -nH --cut-dirs=5 -R "index.html,index.html.tmp" -P ./static/assets/ $FASTUI_ASSETS_URL

@Nosikmov
Copy link

image

just adding that you probably also need the other files (CodeLazy.js, Markdown...)?

FASTUI_ASSETS_VERSION=0.0.23
FASTUI_ASSETS_URL=https://cdn.jsdelivr.net/npm/@pydantic/fastui-prebuilt@$FASTUI_ASSETS_VERSION/dist/assets/
wget -r -np -nH --cut-dirs=5 -R "index.html,index.html.tmp" -P ./static/assets/ $FASTUI_ASSETS_URL

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

4 participants