Created
June 17, 2018 16:45
-
-
Save dgnsrekt/ed28c3631773e2ad6cdaa6e4733455fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
import flask | |
import os | |
app = dash.Dash() | |
app.layout = html.Div('Hello World') | |
# Add a static image route that serves images from desktop | |
# Be *very* careful here - you don't want to serve arbitrary files | |
# from your computer or server | |
css_directory = os.getcwd() | |
stylesheets = ['stylesheet.css'] | |
static_css_route = '/static/' | |
@app.server.route('{}<stylesheet>'.format(static_css_route)) | |
def serve_stylesheet(stylesheet): | |
if stylesheet not in stylesheets: | |
raise Exception( | |
'"{}" is excluded from the allowed static files'.format( | |
stylesheet | |
) | |
) | |
return flask.send_from_directory(css_directory, stylesheet) | |
for stylesheet in stylesheets: | |
app.css.append_css({"external_url": "/static/{}".format(stylesheet)}) | |
if __name__ == '__main__': | |
app.run_server(debug=True) | |
#https://github.com/plotly/dash/issues/71 | |
#https://community.plot.ly/t/how-do-i-use-dash-to-add-local-css/4914/3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment