Last active
January 25, 2022 08:25
-
-
Save xhluca/8b282b51477d2676c9fbf246e83d918d to your computer and use it in GitHub Desktop.
Template of Dash app with preformatted CSS
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 os | |
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
import pandas as pd | |
import numpy as np | |
import plotly.graph_objs as go | |
from dash.dependencies import Input, Output, State | |
app = dash.Dash(__name__) | |
server = app.server | |
# Custom Script for Heroku | |
if 'DYNO' in os.environ: | |
app.scripts.append_script({ | |
'external_url': 'https://cdn.rawgit.com/chriddyp/ca0d8f02a1659981a0ea7f013a378bbd/raw/e79f3f789517deec58f41251f7dbb6bee72c44ab/plotly_ga.js' | |
}) | |
app.layout = html.Div([ | |
# Banner display | |
html.Div([ | |
html.H2( | |
'App Name', | |
id='title' | |
), | |
html.Img( | |
src="https://s3-us-west-1.amazonaws.com/plotly-tutorials/logo/new-branding/dash-logo-by-plotly-stripe-inverted.png" | |
) | |
], | |
className="banner" | |
), | |
# Body | |
html.Div([ | |
], | |
className="container", | |
) | |
]) | |
external_css = [ | |
"https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css", # Normalize the CSS | |
"https://fonts.googleapis.com/css?family=Open+Sans|Roboto" # Fonts | |
"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css", | |
"https://cdn.rawgit.com/xhlulu/0acba79000a3fd1e6f552ed82edb8a64/raw/dash_template.css" # For production | |
] | |
for css in external_css: | |
app.css.append_css({"external_url": css}) | |
# Running the server | |
if __name__ == '__main__': | |
app.run_server(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment