test out python interop again with a super simple example
Bobby Grayson 1 day ago 6 files (+45, -291)
MODIFIED
lib/blog/application.ex
MODIFIED
lib/blog/application.ex
@@ -7,6 +7,20 @@ use Application@impl truedef start(_type, _args) do+ # Start :inets application - needed by Pythonx+ :ok = Application.ensure_started(:inets)++ # Configure Pythonx environment variables+ # Point to Python executable found via SSH+ System.put_env("PYTHONX_PYTHON_PATH", "/usr/bin/python3")+ # Use a directory with write permissions - changed from /tmp/pythonx_cache to /tmp+ System.put_env("PYTHONX_CACHE_DIR", "/tmp")+ # Disable download of binaries (use system Python)+ System.put_env("PYTHONX_SKIP_DOWNLOAD", "true")++ # Create cache directory with proper permissions+ File.mkdir_p!("/tmp/pythonx_venv")+# Create the ETS table for Reddit links:ets.new(:reddit_links, [:named_table, :ordered_set, :public, read_concurrency: true])
DELETED
lib/blog/python_runner.ex
DELETED
lib/blog/python_runner.ex
This file has been deleted in this commit.
MODIFIED
lib/blog_web/channels/user_socket.ex
MODIFIED
lib/blog_web/channels/user_socket.ex
@@ -1,13 +1,41 @@defmodule BlogWeb.UserSocket douse Phoenix.Socket- channel "skeet:*", BlogWeb.SkeetChannel+ # A Socket handler+ #+ # It's possible to control the websocket connection and+ # assign values that can be accessed by your channel topics.++ ## Channels+ channel "fireworks", BlogWeb.FireworkChannel+ # Socket params are passed from the client and can+ # be used to verify and authenticate a user. After+ # verification, you can put default assigns into+ # the socket that will be set for all channels, ie+ #+ # {:ok, assign(socket, :user_id, verified_user_id)}+ #+ # To deny connection, return `:error` or `{:error, term}`. To control the+ # response the client receives in that case, use `{:error, :reason, response}`+ #+ # See `Phoenix.Token` documentation for examples in+ # performing token verification on connect.@impl truedef connect(_params, socket, _connect_info) do{:ok, socket}end+ # Socket id's are topics that allow you to identify all sockets for a given user:+ #+ # def id(socket), do: "user_socket:#{socket.assigns.user_id}"+ #+ # Would allow you to broadcast a "disconnect" event and terminate+ # all active sockets and channels for a given user:+ #+ # Elixir.BlogWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})+ #+ # Returning `nil` makes this socket anonymous.@impl truedef id(_socket), do: nilend
This file has been deleted in this commit.
MODIFIED
lib/blog_web/router.ex
MODIFIED
lib/blog_web/router.ex
@@ -31,6 +31,7 @@ live "/emoji-skeets", EmojiSkeetsLive, :indexlive "/allowed-chats", AllowedChatsLive, :indexlive "/hacker-news", HackerNewsLive, :indexlive "/python", PythonLive.Index, :index+ live "/python-demo", PythonDemoLive, :indexend# Other scopes may use custom stacks.
MODIFIED
mix.exs
MODIFIED
mix.exs
@@ -21,7 +21,7 @@ # Type `mix help compile.app` for more information.def application do[mod: {Blog.Application, []},- extra_applications: [:logger, :runtime_tools, :inet]+ extra_applications: [:logger, :runtime_tools, :inets]]end