Get The (Actual) Current URL #4000
-
QuestionHello there, 🙂 I'm trying to get the current URL that is being used on a browser for monitoring purposes on a site I'm working on. I'm currently using the following approach: from nicegui import context, ui
@ui.page("/{user}/{pet}")
def page_home(user: str, pet: str, source: str = None):
print(context.client.page.path)
ui.run() Browser URL:
Output:
The problem with this is that is that I can't truly see what the user accessed. I could implement some sort of parsing function that could interpret the parameter injection from the Before I implement something, I want to ask if there's an actual proper Thanks for reading! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @PoshoDev, Luckily you can access the current FastAPI request object which contains the requested URL: @ui.page("/{user}/{pet}")
def page_home(user: str, pet: str, source: str = None):
print(ui.context.client.request.url) Apart from the complete URL it contains useful properties like |
Beta Was this translation helpful? Give feedback.
Hi @PoshoDev,
Luckily you can access the current FastAPI request object which contains the requested URL:
Apart from the complete URL it contains useful properties like
base_url
,path_params
,query_params
etc.