OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Is there any alternative for webbrowser module that it will work in cloud run?

  • Thread starter Thread starter user16071
  • Start date Start date
U

user16071

Guest
Assume the following code. I want to replace webbrowser because it does not work when I deploy my app in cloud run.

Ideally, when the button is clicked, I would like to open a new tab in the browser which the user currently uses for the app.

Code:
import chainlit as cl
import webbrowser


@cl.action_callback("Open tab")
async def on_action(action: cl.Action):
    url = "https://www.google.com"
    webbrowser.open(url, new=2)


@cl.on_message
async def on_message(message: cl.Message):
    response = f"Hello, you just sent: {message.content}!"
    actions = [
        cl.Action(name="Open tab", value="example_value")
    ]
    msg = cl.Message(content=response, actions=actions)
    await msg.send()

The code works locally but there is no new tab opened when the app is deployed to cloud run.
<p>Assume the following code. I want to replace webbrowser because it does not work when I deploy my app in cloud run.</p>
<p>Ideally, when the button is clicked, I would like to open a new tab in the browser which the user currently uses for the app.</p>
<pre><code>import chainlit as cl
import webbrowser


@cl.action_callback("Open tab")
async def on_action(action: cl.Action):
url = "https://www.google.com"
webbrowser.open(url, new=2)


@cl.on_message
async def on_message(message: cl.Message):
response = f"Hello, you just sent: {message.content}!"
actions = [
cl.Action(name="Open tab", value="example_value")
]
msg = cl.Message(content=response, actions=actions)
await msg.send()
</code></pre>
<p>The code works locally but there is no new tab opened when the app is deployed to cloud run.</p>
 

Latest posts

Top