Use auth-module and log-file from pn.serve

Hi,

I am trying to use the auth-module and log-file from pn.serve to be invoked with python main_app.py.

the auth.py is copied from

If I run the app

import panel as pn 
def get_page1():
    return 'hola'
get_page1().servable()

with

panel serve --show --autoreload main_app.py --rest-session-info -session-history=-1 --log-file='log_panel' --auth-module=auth.py

It works perfectly the auth module and the log file is written to the specified file. If i use the pn.serve running inside a python script with ‘python main_app.py’

import panel as pn 
def get_page1():
    return 'hola'

pn.serve({'app11':get_page1},show=True,autoreload=True,session_history=-1,
port=5007,address='147.47.240.86',host="0.0.0.0",allow_websocket_origin=['*'],
rest_session_info=True,auth_module='auth.py', log_file='log_panel')

the app runs, but the auth and the log file do not work.

If someone is using them I would be very gratefull for the help.

2 Likes

Did you find a solution to this? Am also trying to use the bokeh example auth.py with the pn.serve inside the app’s python script and am having the same issue where the auth file doesn’t work.

to make it working from pn.serve and running python app.py I did not find a solution yet, but it works if you make your app.servable() and you run “panel serve --show --autoreload main_app.py --rest-session-info -session-history=-1 --log-file=‘log_panel’ --auth-module=auth.py” with the auth module enabled.

I think some options in the docs should be clearly explicited how to call them when using in panel serve and when in pn.serve.

for auth_module, you can use

from bokeh.server.auth_provider import AuthModule
 server = pn.serve(
        {'app11':get_page1},
        auth_provider=AuthModule("auth.py"),...
)
3 Likes