Closed katenguyen10 closed 7 months ago
I know this isn't exactly what we were discussing we would do but there is a new tool from Anaconda that allows you to write HTML code and with python. Although we would have to learn a whole new completely different framework this would make implementing the python script easier. In the website below it list a lot of example sites as well we can use for reference. https://pyscript.net/
I'm going to take a look at all of the links that Colby has supplied and see if I can start finding things that would work for having a python call from the website
I've found this on integrating python into html: https://stackoverflow.com/questions/48552343/how-can-i-execute-a-python-script-from-an-html-button This looks fairly easy to do, and I can do a test in my branch once we start making our webpage. As reported in #6 by colby, we may be able to convert our prototype into html, so hopefully this is of use.
In addition, this link should help create a file upload button: https://www.w3schools.com/howto/howto_html_file_upload_button.asp and also here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
These should serve for a decent starting point to getting the file uploads working
I attempted to try and add in the buttons for the file import and script generate button. The file import buttons are not formatted right but they are functional. As for python script I will try and see if I can get Flask to work. I have uploaded the source in my branch under the main.html file.
I followed the instructions to create a simple Flask server. It might be feasible to implement our script using that method but I'm unsure how complicated it might be to learn it. If anyone wants to check it out under script file in my branch. To run it on your own machine you will need to download Flask by using the commands pip install flask
or pip3 install flask
and then use the command python3 server.py
or python server.py
from within the script file system. Then you should be able to preview your page by going to the link http://127.0.0.1:5000. For better instructions look at the comment from this link that Mark found.
https://stackoverflow.com/questions/48552343/how-can-i-execute-a-python-script-from-an-html-button
I started to research pyscript a little bit more and it's seeming like a more viable option. There are many ways that you can read in a local file which is very helpful for us. I have also started on a proof of concept and will push it when I get it working. https://www.jhanley.com/blog/pyscript-files-and-file-systems-part-1/
I got a working example website running that takes in a csv and displays it using Panda in pyscript. Essentially it takes in the dummy csv which is supplied in the link below and just displays in a simple fashion.
The main issues are that it won't recognize csv files that are in my local file system and the format of the original templates are currently incompatible. I will continue to troubleshoot some of these issues but for now a working website outline can run off of Flask and pyscript concurrently.
I'm going to go ahead and try to create a site that runs a python script. I've already merged colby's code into my branch so I can use that as a starting point and I'll post my findings here
I've created a local server environment on my computer run through python, which I followed through the original link I pasted. However, this was making a server in python, not running the script. I followed https://stackoverflow.com/questions/40844903/how-can-i-run-a-python-script-in-html to try and call a script but I have yet to be successful. I'm going to keep working on this and see what I can get working, I may look into pyscript as well, depending on what happens
I also got a simple flask server running on my raspberry pi if we wanted to test out our website without the worry of using up our credits. https://towardsdatascience.com/python-webserver-with-flask-and-raspberry-pi-398423cc6f5d
I'm going to keep working on getting a python script working through an html or php page
I'm taking a good look into pyscript at the moment. I created an account to do some tests on https://pyscript.net/ which have yet to work in my personal vs code environment. That being said, it does seem promising and I feel the best about using it because it is specifically made for running python scripts. I'm going to keep working at it to see if I can get something working
I've successfully been able to call (a very simple) python script with pyscript in a local environment. All of that code is in my branch under the python-html-testing folder. I adapted it directly from https://pyscript.com/@8785b7b2-8081-4a5b-82d8-791eb306f8ac/simple-clock-copy/latest. I also got some help from this link: https://pyscript.github.io/docs/2024.1.3/beginning-pyscript/. I'll clean some code up and make the test site better before I merge it back into main, but this is definitely a promising development
While I was successful in having a python script be run from a local environment, I want to familiarize myself with it and see if I can maybe incorporate some css into it as well to get a better basis.
I've been making alterations and I can confirm that a python script can write lines into a table. I'm going to look into seeing if I can define something to be able to change the size of the table based on the python script
I'm going to go ahead and merge my branch back into main as there is some good progress made on how we could add in a python script. Pyscript seems promising but I either need to look into having a php script, a JS script, or look more into pyscript. I think I'll make a new issue to document specific interactions with python and html, but I'll keep this open for general issues as we figure out our website
Going to go ahead and close this out since we have not been using it, but if we need to open it up again, we can.
We need to decide what to host the website on and make sure it can fit all the requirements.