I wish to set up my deployed panel application for bunch of users who would have restricted access to the app. This is a sample code for it:
import panel as pn
pn.extension()
bal = pn.pane.Markdown("bal")
jobb = pn.pane.Markdown("jobb")
cred_bal = {'bal':'bal'}
cred_jobb = {'jobb':'jobb'}
logout = pn.widgets.Button(name="Log out")
logout.js_on_click(code="""window.location.href = './logout'""")
pn.serve(pn.Column(**user**,logout), basic_auth = **cred_user**, cookie_secret = 'secret')
So user would change depending on credentials.
I would need a hint to how to approach this problem.
Update
THis is my next try. I am not sure how I can return the specific user content with the serve function as I get 500 internal server error for this try.
import panel as pn
pn.extension()
bal = pn.pane.Markdown("bal")
jobb = pn.pane.Markdown("jobb")
credendtials = {'bal':'bal','jobb':'jobb'}
logout = pn.widgets.Button(name="Log out")
logout.js_on_click(code="""window.location.href = './logout'""")
def render_content(user):
if username == 'bal':
return pn.Column(bal,logout)
elif username == 'jobb':
return pn.Column(jobb,logout)
else:
return pn.Column(pn.pane.Markdown("Unauthorized"),logout)
pn.serve(lambda request: render_content(request.auth), basic_auth=credendtials,
cookie_secret='my_secret')