Calling on Web Dev file in doGet python resource?

I have a Python doGet script that I'm trying to read a html file, and I’ve been trying system.file.readFileAsString and I couldn’t get it to work with the mounted path or normal path and when I try system.file.fileExists I get false on all of the paths I could think to try. so, I'm kind of loss I feel like surely there has to be a way to split up the code. I hope I'm just missing something obvious

I figured it out I needed to use system.net.httpGet() and convert to a string instead of system.file.readFileAsString()

1 Like

Why in the world would you have WebDev call back into itself to retrieve the file? Horribly inefficient. Just read the file directly, using the mount location plus leaf path.

why would I do it like that, the answer is because I don’t know what I'm doing. this is my first year working as a developer let alone using ignition. I’m the only Scada developer that will touch the web dev module where I work, so I'm kind of going in dark since I have no prior usage of JavaScript, html or CSS besides the small amount I did in college. the ignition manual doesn’t go into depth on web dev and there aren’t many threads that go into detail on this forum. I'm not asking for a teacher, but would you mind explain what you mean by using the leaf paths, and perhaps point me towards some information to help get a better grasp of the correct practices?

In your first screenshot, you see the HomePage.html resource under Shred_Bag_Charts. Look at that resource to see where IT is getting the file. If that resource is a simple mount, then the file path will be right there in the configuration. If that resource is a doGet script, you would look at what its script does, and replicate that in your main resource.

I strongly recommend that you have your script resources be one-liners pointing at a project library script function, passing the given arguments. That also allows you to share common code among multiple callers. Also:

Please see Wiki - how to post code on this forum.

it looks like you were running the system.file.* functions from a script console. Note that running these from the script console will attempt to access files on the machine that the Designer is running on (your PC), which is not always the gateway where the resources are hosted. In order to read a WebDev resource on the gateway from script console running on a different machine, you were correct in using a system.net.* function.

Put another way, your system.file.* functions may have worked perfectly in the doGet method.