FastUI
FastUI copied to clipboard
It works only with internet
Why did this framework is working only with internet? I mean, it is not in local network without internet...
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.
You could probably do the following:
- download the js and css files locally:
- https://cdn.jsdelivr.net/npm/@pydantic/[email protected]/dist/assets/index.js
- https://cdn.jsdelivr.net/npm/@pydantic/[email protected]/dist/assets/index.css
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'
...
You could probably do the following:
- download the js and css files locally:
- https://cdn.jsdelivr.net/npm/@pydantic/[email protected]/dist/assets/index.js
- https://cdn.jsdelivr.net/npm/@pydantic/[email protected]/dist/assets/index.css
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 Great! Thanks for the note about importing StaticFiles :)
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
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