0

I have a python file on my server. I want to run this file whenever user clicks submit button. Both my files .py and .html are in different directories. And I also cant use any framework

How to do this?

3
  • 2
    use Python framework like Django, Flask, Bottle to create web page. And you need server which can run Python code - Django,Flask, Bottle - or it uses CGI to run scripts in different languages - or it can run PHP which could run Python code. Using only HTML and JavaScript you can't run Python code Commented Feb 24, 2020 at 11:54
  • Agree on @vishakha-mishra comment. You'll need some server side technology to do that. As you want to run a python script, I'd suggest using some python web framework. Commented Feb 24, 2020 at 12:25
  • flask is the simplest flask.palletsprojects.com/en/1.1.x/quickstart Commented Mar 3, 2020 at 3:18

1 Answer 1

1

One option (as suggested by furas) is to use a python framework (Django, Flask, Bottle) on the backend to create an API server. You could equally do this in node with a call to require('child_process').exec()

The other older method is to configure FastCGI on your webserver, which can automatically turn your python file into a url. Here are some stackoverflow answers for that method:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.