You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defmoduleLVPdo@moduledoc""" Documentation for `LVP`. Quick hack to serve via livebook hosted in docker. Accept connections from other hosts to the internal port. """defstart(opts\\[])dorouter=Keyword.get(opts,:router,LiveviewPlayground.Router)endpoint=Keyword.get(opts,:endpoint,LiveviewPlayground.Endpoint)ip=Keyword.get(opts,:ip,{127,0,0,1})port=Keyword.get(opts,:port,4000)check_origin=Keyword.get(opts,:check_origin,true)LiveviewPlayground.ProxyRouter.set_router(router)Application.put_env(:liveview_playground,endpoint,http: [ip: ip,port: port],server: true,live_view: [signing_salt: "aaaaaaaa"],check_origin: check_origin,secret_key_base: String.duplicate("a",64))Application.put_env(:liveview_playground,:router,router){:ok,_}=Supervisor.start_link([endpoint],strategy: :one_for_one)Process.sleep(:infinity)endend
defmodulePageLivedouseLiveviewPlaygroundWeb,:live_viewdefmount(_params,_session,socket)do{:ok,assign(socket,:count,0)}enddefrender(assigns)do~H""" Counter: <%=@count %><buttonphx-click="inc">+</button><buttonphx-click="dec">-</button>"""enddefhandle_event("inc",_params,socket)do{:noreply,assign(socket,:count,socket.assigns.count+1)}enddefhandle_event("dec",_params,socket)do{:noreply,assign(socket,:count,socket.assigns.count-1)}endend# listen on all interfaces, allowing connections from non-localhost. # Disable check-origin, as the external IP won't match the internal one. LVP.start(ip: {0,0,0,0},check_origin: false)