0

Update: I don't want to use JS to generate forms or navigate through them

I need to create an application that generates a drop down menu with items obtained from a list of folders in the local host and then generates another drop down menu based on that. Then, based on the second selection it needs to either present a list of scripts or another list of folder after which some other scripts will be available.

When the final script is selected two more fields should show up in which the user should enter and select two more values.

With all these values then a command on the local host will be executed - the values will be passed as parameters.

Can this be done without JS?

I have enough Python/Flask and HTML skills to do this in a reasonable amount of time, but I don't have the necessary JS skills or the time to learn JS. Some pointers would be great :)

Thank you

Lucian
  • 115
  • 2
  • 12
  • I think you can use python functions in the flask backend, to generate a list of folders using the `os` module in python and then feed it into the html front end using jinja tags – Harsh Vedant May 23 '18 at 17:22
  • Yes, that's what I am doing now, but I don't quite know how to handle the cascading drop downs: from A go to B then go to C then go to D... – Lucian May 23 '18 at 17:23
  • Possible duplicate of [Local file access with javascript](https://stackoverflow.com/questions/371875/local-file-access-with-javascript) – Bennett Brown May 23 '18 at 17:27
  • To clarify, are you wanting to run your Flask app on your local machine and use it to access the files on your local machine? – Nathan Hinchey May 23 '18 at 17:50
  • Yes, something like that. I want to execute some scripts from the local machine. I am not concerned about security, this will be used by a limited number of people on an internal IP (with filtering also). – Lucian May 23 '18 at 17:53

1 Answers1

0

Flask executes on the server side and cannot be used to gather directory information about the local host. You need JavaScript, and even there there is not a standard interface that will work across all browsers.

See SO answers here: Local file access with javascript

and MDN documentation for Firefox here: https://developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API

and a more recent SO question with less browser-specific solutions among the answers here: Select directory path in javascript

Bennett Brown
  • 5,234
  • 1
  • 27
  • 35
  • The whole point was to not use JS. Before I present the menu I have a python function that gets the data from the file system and puts it in a JSON. Then my Flask app reads the JSON and presents the menus. So I think this issue can be avoided. Thank you for your answer! – Lucian May 23 '18 at 17:25