# Serve\_locally option with additional scripts and style sheets

**URL:** <https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974>\
**Category:** Dash Python\
**Created:** [November 24, 2017, 7:43am UTC](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974 "2017-11-24T07:43:46Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![delsim](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@delsim](https://community.plotly.com/u/delsim)\
**Post date:** [July 12, 2018, 10:28pm UTC](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974/21 "2018-07-12T22:28:26Z")

</div>

I’ve got a similar issue to @bfauser - I’d like to add extra css and js files to be served, using something like:

```
app.css.append_css({'external_url':'my/file/not/served/by/flask'})

```

This works fine as long as I leave:

```
app.css.config.serve_locally=False

```

but as soon as I set this flag to `True` (it makes my development a lot easier), Dash will silently exclude my file from the html served up in the `index` route of the application.

I’ve traced this behaviour to the `Resources._filter_resources()` function in `dash/resources.py`, where external urls are only served if `serve_locally` is `False`. Is there any reason for this restriction (equivalently: would you welcome a PR that enhances this logic)?

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [July 13, 2018, 12:24am UTC](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974/22 "2018-07-13T00:24:14Z")

</div>

> [@delsim](#):
>
> I’ve traced this behaviour to the `Resources._filter_resources()` function in `dash/resources.py` , where external urls are only served if `serve_locally` is `False` . Is there any reason for this restriction (equivalently: would you welcome a PR that enhances this logic)?

This is getting fixed in [https://github.com/plotly/dash/pull/286](https://github.com/plotly/dash/pull/286)

---

<div class="post-metadata">

**Author:** ![delsim](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@delsim](https://community.plotly.com/u/delsim)\
**Post date:** [July 13, 2018, 4:58am UTC](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974/23 "2018-07-13T04:58:17Z")

</div>

That PR looks really good, but I fear that I have a different use case - admittedly one that is probably an edge case.

I want to set `serve_locally=True` (to serve up the files I’m developing, as well as in general when I don’t have internet access) but also to have other extra files served from somewhere else - essentially some other server.

Right now, I’m using `external_url` in calls to `append_css` and `append_script` to achieve this, along with a patch of `Resources._filter_resources`. From a reading of the code - unfortunately I’ve not been able to try to run it - and the associated github notes, it looks like PR 286 won’t change this. Also, it isn’t really possible for me to cleanly put a copy of the extra files into an `assets_folder` directory that can be scanned by the code in PR 286, although some sort of kludge might work.

Of course, I may have misread things - but if not, I’m still in the same situation.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [July 13, 2018, 6:35am UTC](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974/24 "2018-07-13T06:35:35Z")

</div>

> [@delsim](#):
>
> but also to have other extra files served from somewhere else - essentially some other server.

So with the new PR, you’ll be able to set your own index.html string and then include whatever scripts you want there. We’re also considering adding a scripts=[…] argument in the dash constructor (there are some comments in the PR with more info). Eventually, these methods will replace the existing append\_script interface

---

<div class="post-metadata">

**Author:** ![delsim](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@delsim](https://community.plotly.com/u/delsim)\
**Post date:** [July 14, 2018, 1:48am UTC](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974/25 "2018-07-14T01:48:46Z")

</div>

Setting the index.html will be ideal - thanks!

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [November 20, 2018, 3:19pm UTC](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974/26 "2018-11-20T15:19:50Z")

</div>

A post was split to a new topic: [Serve assets directory from server?](https://community.plotly.com/t/serve-assets-directory-from-server/15825)

---

<div class="post-metadata">

**Author:** ![luggie](https://avatars.discourse-cdn.com/v4/letter/l/0ea827/32.png) [@luggie](https://community.plotly.com/u/luggie)\
**Post date:** [May 8, 2024, 8:30am UTC](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974/27 "2024-05-08T08:30:06Z")

</div>

> [@chriddyp](#):
>
> ```auto
> app.css.config.serve_locally = True
> app.scripts.config.serve_locally = True
> 
> ```

Is something like this still possible somehow?  
I’d like to locally serve some .css files.  
However I do not wish to apply them directly by putting them into `/assets/`. I’d need them to be available for the server at e.g. `/external_css/theme1.css, /external_css/theme2.css,` …

[Previous page](https://community.plotly.com/t/serve-locally-option-with-additional-scripts-and-style-sheets/6974.md?page=1)
