[Oxygen.jl] returning plots to user

Hi all

My first attempt at putting together a browser-based interface and also any form of web programming, so I really don’t know what it is that I don’t know. Apologies for asking the obvious. I am using Oxygen.jl for this.

I get inputs via an html form and pass that to my functions that generate a few plots and save them to .svg files. I then try to return these to the user via

    html("""
        <img src="./npv.svg" width="600" height="400">
        <img src="./fi.svg" width="600" height="400">
        <img src="./cashflows.svg" width="600" height="400">
        <img src="./pv_cashflows.svg" width="600" height="400">
    """)

This however just puts four empty placeholders in the browser. I also tried with fully qualified filenames and the same thing happens.

The server log shows:

[ Info: 📦 Version 1.7.1 (2025-02-06)
[ Info: ✅ Started server: http://127.0.0.1:8080       
[ Info: 📖 Documentation: http://127.0.0.1:8080/docs  
[ Info: 📊 Metrics: http://127.0.0.1:8080/docs/metrics
[ Info: Listening on: 127.0.0.1:8080, thread id: 1    
[ Info: 2025-02-26T16:41:23 - 127.0.0.1:59247 - "GET /project HTTP/1.1" 200
[ Info: 2025-02-26T16:41:31 - 127.0.0.1:59247 - "POST /form HTTP/1.1" 200

I looked for examples, but came up empty. I am honestly stumped at the moment. How would I return generated plots? Are there any examples somewhere I can look at?

Did you implement handlers for the paths to the svgs? The browser should perform GET requests on your server to retrieve the svg data. Open your browser dev tools window and check for errors in the console and check the network activity. You probably don’t need the ./ in the paths, there are no ./ in the examples here HTML File Paths.

Thanks for the assistance. The server returns 404s, although the .svg files are successfully created in the same folder as the script is running from. Does Oxygen.jl run from a different working directory, or at least expect resources in a specific folder under the project root?

Just to be clear: this is without the “./” in the filename. With a full path, it errors on not allowing local resources. This is at least progress, for which I am grateful.

Solution found here.