# Get File Path with WebDev

**URL:** <https://forum.inductiveautomation.com/t/get-file-path-with-webdev/77021>\
**Category:** Ignition\
**Created:** [July 27, 2023, 3:26pm UTC](https://forum.inductiveautomation.com/t/get-file-path-with-webdev/77021 "2023-07-27T15:26:45Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 27, 2023, 4:07pm UTC](https://forum.inductiveautomation.com/t/get-file-path-with-webdev/77021/4 "2023-07-27T16:07:46Z")

</div>

Start by hardcoding the directory you care about into your Python endpoint.  
Then, you could pay attention to the `remainingPath` request parameter in a Python endpoint:  
[https://docs.inductiveautomation.com/display/DOC81/Web+Dev#WebDev-PythonResources](https://docs.inductiveautomation.com/display/DOC81/Web+Dev#WebDev-PythonResources)

If it's None, then this is a request to the 'root', so you're going to use Java's File class to list the child files in that directory:  
[https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#listFiles()](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#listFiles())  
And assemble that into a JSON payload or whatever else.

If there _is_ a remaining path, then you're going to try to find that file, [load the file](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/FileInputStream.html), and then [write it](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/InputStream.html#transferTo(java.io.OutputStream)) to the [request's output stream](https://docs.oracle.com/javaee/7/api/javax/servlet/ServletResponse.html#getOutputStream--).

# Be careful with file traversal! A malicious actor could pass a relative path like `../../../../etc/passwd` to your endpoint!

To avoid this risk, I'd suggest taking advantage of our [`SecurePathUtils`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.30/com/inductiveautomation/ignition/client/launch/util/SecurePathUtils.html) class.

---

_[View the full topic](https://forum.inductiveautomation.com/t/get-file-path-with-webdev/77021)._
