Skip to content

Instantly share code, notes, and snippets.

@amattn
Last active October 4, 2022 23:20
Show Gist options
  • Save amattn/759553b6670015fab5bfe222d2749b3e to your computer and use it in GitHub Desktop.
Save amattn/759553b6670015fab5bfe222d2749b3e to your computer and use it in GitHub Desktop.
def generate_html_for_route(route_path) do
conn = Phoenix.ConnTest.build_conn()
conn = get(conn, route_path)
resp = html_response(conn, 200)
priv_static_path =
Path.join([
:code.priv_dir(:dash_home),
"static",
route_path
])
assert File.mkdir_p(priv_static_path) == :ok
priv_static_filepath = Path.join([priv_static_path, "index.html"])
{:ok, file} = File.open(priv_static_filepath, [:write])
assert IO.binwrite(file, resp) == :ok
File.close(file)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment