# \[Oxygen.jl\] returning plots to user

**URL:** <https://discourse.julialang.org/t/oxygen-jl-returning-plots-to-user/126341>\
**Category:** Web Stack\
**Tags:** question\
**Created:** [February 26, 2025, 2:44pm UTC](https://discourse.julialang.org/t/oxygen-jl-returning-plots-to-user/126341 "2025-02-26T14:44:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![braamvandyk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/braamvandyk/32/5086_2.png) [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)\
**Post date:** [February 26, 2025, 2:44pm UTC](https://discourse.julialang.org/t/oxygen-jl-returning-plots-to-user/126341/1 "2025-02-26T14:44:49Z")

</div>

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

```julia
    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:

```julia
[ 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?

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [February 26, 2025, 5:19pm UTC](https://discourse.julialang.org/t/oxygen-jl-returning-plots-to-user/126341/2 "2025-02-26T17:19:13Z")

</div>

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](https://www.w3schools.com/html/html_filepaths.asp).

---

<div class="post-metadata">

**Author:** ![braamvandyk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/braamvandyk/32/5086_2.png) [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)\
**Post date:** [February 27, 2025, 6:27am UTC](https://discourse.julialang.org/t/oxygen-jl-returning-plots-to-user/126341/3 "2025-02-27T06:27:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![braamvandyk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/braamvandyk/32/5086_2.png) [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)\
**Post date:** [February 27, 2025, 7:06am UTC](https://discourse.julialang.org/t/oxygen-jl-returning-plots-to-user/126341/4 "2025-02-27T07:06:56Z")

</div>

Solution found [here](https://discourse.julialang.org/t/simplest-way-to-display-a-picture-in-a-webapp-with-genie-jl/60387/4).

---

<div class="post-metadata">

**Author:** ![ndortega](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ndortega/32/37018_2.png) [@ndortega](https://discourse.julialang.org/u/ndortega)\
**Post date:** [September 26, 2025, 4:08am UTC](https://discourse.julialang.org/t/oxygen-jl-returning-plots-to-user/126341/5 "2025-09-26T04:08:09Z")

</div>

Hi @braamvandyk,

As an alternative you can use the `staticfiles()` function to mount your files to the web server. This function will recursively walk through the given directory and generate routes for each discovered file. These files will be loaded once into memory on startup - which is perfect for static assets.

```julia
using Oxygen

# mount all files inside the "./images" folder under the "/public" path
staticfiles("./images", "public")

# start the web server
serve()

```

With that setup you could then call `http://localhost:8080/public/npv.svg` or return this html string from a function handler to load the image: `<img src="/public/npv.svg" width="600" height="400">`

* * *

If you want/need more control over what the endpoint returns you can also use the `file()` render function to directly return a file from the route handler. [file() render function docs](https://github.com/OxygenFramework/Oxygen.jl/blob/v1.7.5/src/utilities/render.jl#L125)

```julia
using Oxygen

@get "/photo" function()
    return file("./images/my-photo.png")
end

serve()

```
