def test1(server):
    app = dash.Dash(server=server,
                         routes_pathname_prefix='/dashapp/',
                         external_stylesheets=[
                             'https://codepen.io/dapraxis/pen/gOPGzPj.css',
                             '/static/dist/css/styles.css',
                             'https://fonts.googleapis.com/css?family=Lato'
                             ])

    dash_resumable_upload.decorate_server(app.server, "uploads")
    
    app.index_string = html_layout

    app.scripts.config.serve_locally = True  # Uploaded to npm, this can work online now too.

    app.layout = html.Div([
        dash_resumable_upload.Upload(
            id='upload-data',
            maxFiles=1,
            maxFileSize=1024*1024*1000,  # 100 MB
            service="/upload_resumable",
            textLabel="Drag and Drop to upload",
            # startButton=True
        ),
        html.Div(id='output')
        ],style={
            'width': '70%',
            'margin': '5% 15%',
            'text-align': 'center',
        })


    @app.callback(Output('output', 'children'),
                [Input('upload-data', 'fileNames')])
    def update_output(list_of_names):
        if list_of_names is not None:
            children = [parse_contents(filename) for filename in list_of_names]
            return children
        
    def parse_contents(filename):
        try:
            if 'csv' in filename:
                # Assume that the user uploaded a CSV file
                df = pd.read_csv("uploads/%s" % (filename))
            elif 'xls' in filename:
                # Assume that the user uploaded an excel file
                df = pd.read_excel(io.BytesIO(decoded))
        except Exception as e:
            print(e)
            return html.Div([
                'There was an error processing this file.'
            ])
        
        size = convert_unit(os.stat(str(os.getcwd())+'/uploads/'+str(filename)).st_size, SIZE_UNIT.MB)

        return html.Div([
            html.H5("Upload File: {}".format(filename)),
            html.H5("File size: {:.3f}MB".format(size)),
            dash_table.DataTable(
                id='database-table',
                columns=[{'name': i, 'id': i} for i in df.columns],
                data=df[:1000].to_dict('records'),
                sort_action="native",
                sort_mode='native',
                page_size=300,
                fixed_rows = 100,
                style_table={
                    'maxHeight': '80ex',
                    'overflowY': 'scroll',
                    'overflowX': 'scroll',
                    'width': '100%',
                    # 'minWidth': '100%',
                    # 'margin': '5% 15%'
                },
            ),

            html.Hr(),  # horizontal line
            html.A(html.Button('Next', id='btn'), href='/EDA')
        ])
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_resumable_upload
import plotly.graph_objs as go
import redis
from dash.dependencies import Input, Output, State
from flask_caching import Cache

import stormwater_harvesting

app = dash.Dash(__name__)
server = app.server
app.config['suppress_callback_exceptions']=True

dash_resumable_upload.decorate_server(server, "uploads")

DF = stormwater_harvesting.parse_dnrm_data(r"notebooks\data\143028A.csv")

CACHE_CONFIG = {
    'CACHE_TYPE': 'redis',
    'CACHE_REDIS_URL': os.environ.get('REDIS_URL', 'localhost:6379')
}
cache = Cache()
cache.init_app(server, config=CACHE_CONFIG)

r = redis.from_url(CACHE_CONFIG['CACHE_REDIS_URL'])

app.css.append_css({
    'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css',
    # 'external_url': "https://codepen.io/rmarren1/pen/eMQKBW.css",
    for root, dirs, files in os.walk(file_path, topdown=False):
        for name in files:
            os.remove(os.path.join(root, name))
        for name in dirs:
            os.rmdir(os.path.join(root, name))

logo = 'Images/logo.png'
marker = 'Images/figure-markers.png'
warning = 'Images/warning-icon.png'
logo_encoded = base64.b64encode(open(logo, 'rb').read())
markers_encoded = base64.b64encode(open(marker, 'rb').read())
warning_encoded = base64.b64encode(open(warning, 'rb').read())

dir_path = "uploads"

example_file = 'data/example_Weight_loss_study.txt'

platelet_contamination_markers = pd.read_excel('data/Marker List.xlsx', sheet_name='Platelets')
erythrocyte_contamination_markers = pd.read_excel('data/Marker List.xlsx', sheet_name='Erythrocytes')
coagulation_contamination_markers = pd.read_excel('data/Marker List.xlsx', sheet_name='Coagulation')

# start Flask server
if __name__ == '__main__':

    clean_directory(dir_path)

    decorate_server(app.server, dir_path)
    app.scripts.config.serve_locally = True  # Uploaded to npm, this can work online now too.

    app.run_server(debug=True, use_reloader=False, threaded=True)
示例#4
0
# Display all columns when printing dataframes to console
pd.set_option('display.max_columns', 500)

# App setup
app = dash.Dash(__name__)
app.scripts.config.serve_locally = True

# !! BasicAuth causes a Safari "Failed to load resource: the server responded
#       with a status of 403 (FORBIDDEN)" error after serveral seconds disable
#       authorization until this bug can be fixed
# Authentication
# USERNAME_PASSWORD_PAIRS = [['weaverlab', 'lava']]
# auth = dash_auth.BasicAuth(app, USERNAME_PASSWORD_PAIRS)

server = app.server
dash_resumable_upload.decorate_server(server, 'uploads')


# Take file input and return dataframe
def parse_file_contents(filename):
    try:
        if '.csv' in filename:
            # Assume that the user uploaded a CSV file
            df = pd.read_csv('uploads/' + filename)
            # Assume that the user uploaded an excel file
        elif '.xls' in filename:
            df = pd.read_excel('uploads/' + filename)
            # Assume that the user uploaded a TSV file
        elif '.tsv' in filename:
            df = pd.read_csv('uploads/' + filename, sep='\t')
        return df
示例#5
0
from dashboard.tab_three import create_tab_three, create_second_upload, create_right_column
from dashboard.file_management import new_match, move_match, delete_selected_rows, load_team_df, check_participation, create_pairs
from dashboard.pitch import draw_pitch, setup_pitch1, setup_pitch2, setup_pitch3, setup_timeline1, setup_timeline2, add_formation

from dashboard.scripts.start_analysis import start_analysis, start_clustering_matches

app = dash.Dash(
    __name__,
    suppress_callback_exceptions=True,
    meta_tags=[{
        "name": "viewport",
        "content": "width=device-width, initial-scale=1"
    }],
)

dash_resumable_upload.decorate_server(app.server, "./uploads")

app.layout = html.Div([
    dcc.Store(id='memory'),
    html.Div(id='dummy', style={'display': 'none'}),
    dcc.Location(id='url', refresh=False),
    html.Div(
        id="banner",
        className="banner",
        children=[
            html.Img(src=app.get_asset_url("Uni-Logo.png")),
            html.Img(src=app.get_asset_url("ISS-Logo.png")),
            html.Img(src=app.get_asset_url("DFB-Logo.png"))
        ],
    ),
    dcc.Tabs(id="tabs",