Good day sirs!
Long time php coder here, I just made my first python code on visual code to get json data from an API, I installed python on my windows pc and it runs perfectly. I just uploaded my file.py code to a tomcat server folder and when I try to access it from the browser expecting it to run I get a prompt to download it. What I’m doing wrong? Help please!
Thanks in advance!
Good day sirs!
You’re not doing anything wrong; it’s just that your expectation is misplaced.
A web browser will not run a Python script; thus it invites you to d/load said script, so that you can run it via your Python interpreter.
To put that into terms that you already know: a web browser will not run the PHP code, rather the code is run on the PHP server and the resulting output is then rendered by the web browser.
Thanks for the reply! So how do I get the server to run the code from the file and not ask me if I want to download it?
I suspect that’s a Tomcat question.
Are you planning on developing a Web Application? If so, then maybe take a look at the Flask project. It’s not something that I have done [Web App development], but I can say that before you start down that road, you should take some time to learn as much as you can about Python coding in general, so that you can better understand the coding process involved, from a Python perspective.
Given that you’ve coded PHP, you’re in a better position than someone who has zero prior knowledge of coding concepts and principles.
As for having Tomcat involved with this process; I can’t advise you on that, for the same reason: Ive never developed a Python based Web Application.
Thanks for the answer! I will look for tomcat help!