So I'm creating a website and I was wondering if I could create a button / link to open a FILE, not another website, but a .py file. -Thanks
Use any lightweight python web framework like Flask.
Then use a script like this to run it on a website:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
#do your things here
return "It works!"
if __name__ == "__main__":
app.run()
Then run the server : python script. py
Now the server is running on port 5000
So when you visit (eg: http://rasp_pi_ip:5000/ ) the website, your script will run.
We have object tag in html. You create one button and an object. When u click on the button then you have to change the data attribute value of object tag. It will work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.