Simple HTTP directory within Phoenix

I am creating a Phoenix webapp, and some portion of this will incorporate an existing app that is served as a static webpage.

For instance, if I were to navigate to this directory, and create a Python server with

'python -m SimpleHTTP ’

This works.

Can I make this simple HTTP structure happen in some portion of my Phoenix app, while maintaining regular Phoenix functionality elsewhere? I have been able to get it (kind of) working by creating an ‘index.html.eex’ page, and then creating eex references to static javascript resources that I’ve put into /priv/static/js, like this:

[<script src="<%= static_path(@conn, “/js/subdir/myscript.js”) %>">]

This works for some things, but then there are further references that have to be cleaned up, re-routed in the javascript etc. and I’m wondering if there’s a better way to do this/if I’m going down the right path.

Thanks for any help!

I would probably move out this functionality into a separate app and serve its priv via Plug.Static or just cowboy.

1 Like

I am interested in passing messages back and forth to this part of the app via GenServers. i.e. I want it to be a supervised process among a number of other processes. Would this still be possible?

Yep, a library is often a full Application with a full supervision tree and all. :slight_smile: