Skip to content

Provide documentation on how to use FastUI with local copies of js/css files #309

Open
@jimkring

Description

@jimkring

Sometimes it's nice to use FastUI's python integration with local copies of the js/css files:

  • Situations where there is no Internet/CDN connectivity, such as behind a corporate firewall (See It works only with internet #307)
  • When using/testing custom builds of the TypeScript components

Instructions might look something like:

Using Local Copies of the JS/CSS files:

  1. download the js and css files locally (ensure you have the correct version numbers, since these links are just examples):
  1. Place index.js and index.css in a folder under your fastapi/flask project where you serve static files, for example inside a static/assets folder.

  2. Configure fastapi and fastui as something like the following. Note that the key is to set the fastui._PREBUILT_CDN_URL variable that fastui uses for defining the location of the JS/CSS files, when generating the HTML pages.

from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
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'

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions