FastUI icon indicating copy to clipboard operation
FastUI copied to clipboard

It works only with internet

Open ronvaleron opened this issue 9 months ago • 6 comments

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

ronvaleron avatar May 06 '24 06:05 ronvaleron

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 avatar May 06 '24 08:05 jimkring

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'

...

jimkring avatar May 06 '24 08:05 jimkring

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

ronvaleron avatar May 06 '24 08:05 ronvaleron

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

jimkring avatar May 06 '24 14:05 jimkring

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

simonryf avatar May 17 '24 17:05 simonryf

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

Nosikmov avatar May 31 '24 09:05 Nosikmov