-1

Well I am working on a project where I want to click on a button(html) and it will run a python code in Pycharm(or any ide). For front end I am using Vs code. Is it possible?

  • https://stackoverflow.com/questions/48552343/how-can-i-execute-a-python-script-from-an-html-button/48552490 – Achille G Jul 23 '21 at 09:31
  • To be a bit more correct, vs code is not a front-end nor is pycharm a back-end, front-end consists of html, css and js, while back-end can be python, php, and/or other languages, also this means that you can't directly run python code in html – Matiiss Jul 23 '21 at 12:25

1 Answers1

0

You can try flask and write an HTML template. With a button in HTML can GET or POST method to reach some flask route,then you can run some python code you want.

from flask import Flask
app = Flask(__name__)
@app.route('/endpoint')
def point():
    # some python code
    pass
app.run()
Vincent55
  • 33
  • 3
  • Well I want to run the code from .html file. Which will direct to the python code. It is possible with the GET and POST method right? As I'm getting "Cannot GET /my-link/" error. – Mahmuda Keya Jul 23 '21 at 11:38
  • 1
    can you show me your code? – Vincent55 Jul 23 '21 at 12:16
  • I want to click a button from .html file, then it should run .py file. As i am already running server from vs code, do I still need to run it from python? I am following the first code(answer) from here. https://stackoverflow.com/questions/48552343/how-can-i-execute-a-python-script-from-an-html-button – Mahmuda Keya Jul 23 '21 at 15:27
  • Solved though. Thank you for helping. – Mahmuda Keya Jul 23 '21 at 17:19