Ejemplo n.º 1
0
def router(pathname):
    """
    routes to correct page based on pathname
    """
    print('routing to', pathname)
    # auth pages
    if pathname == '/login':
        if not current_user.is_authenticated:
            return login.layout()
    elif pathname == '/register':
        if not current_user.is_authenticated:
            return register.layout()
    elif pathname == '/change':
        if not current_user.is_authenticated:
            return change_password.layout()
    elif pathname == '/forgot':
        if not current_user.is_authenticated:
            return forgot_password.layout()
    elif pathname == '/logout':
        if current_user.is_authenticated:
            logout_user()

    # app pages
    elif pathname == '/' or pathname == '/home' or pathname == '/home':
        if current_user.is_authenticated:
            return home.layout()
    elif pathname == '/profile' or pathname == '/profile':
        if current_user.is_authenticated:
            return profile.layout()
    elif pathname == '/classification' or pathname == '/classification':
        if current_user.is_authenticated:
            return classification.layout()
    elif pathname == '/training' or pathname == '/training':
        if current_user.is_authenticated:
            return training.layout()

    # DEFAULT LOGGED IN: /home
    if current_user.is_authenticated:
        return home.layout()

    # DEFAULT NOT LOGGED IN: /login
    return login.layout()
Ejemplo n.º 2
0
def router(pathname):
    print('routing to', pathname)
    if not current_user.is_authenticated:
        if pathname in ['/', '/login', '/home']:
            return login.layout()
        elif pathname == '/register':
            return registration.layout()

    if current_user.is_authenticated:
        if pathname == '/logout':
            logout_user()
            return login.layout()
        elif pathname == '/' or pathname == '/home':
            return home.layout()
        elif pathname == '/profile':
            return profile.layout()

    return html.Div(html.Strong(html.H1('Error 404! Page not found!')),
                    style=dict(textAlign='center'))
Ejemplo n.º 3
0
def display_page(pathname):
    if pathname is None:
        return ""

    page_type = url_parser(pathname)

    if page_type == 'home':
        return home.layout(pathname)
    elif page_type == 'project':
        return project.layout(pathname)
    elif page_type == 'combination':
        return combinations.layout(pathname)
    elif page_type == 'matrix':
        return matrix.layout(pathname)
    elif page_type == 'documentation':
        return documentation.layout(pathname)
    elif page_type == 'downloads':
        return downloads.layout(pathname)

    else:
        return '404'