This question may seems a little bit silly, but what the heck. I started to lear
ID: 650228 • Letter: T
Question
This question may seems a little bit silly, but what the heck.
I started to learn Python. I know basic syntax, etc.
When I work with HTML, PHP, etc., I simply write code, put it inside .html or .php file and double click this file. Then my code runs. I can work with databases and other stuff - it's just simple. But how does Python work? I'm working inside Eclipse or Python command line and I can run this code, but what if I want make website with Python for example?
I don't think it's like I put .py file on my server, so what I need to do? I understand I need to install Python on my webserver through some server command line (I've never used it, but I will find some tutorials day I will need it) but what's next? How can I combine my Python knowledge with HTML, CSS, PHP, etc.?
Python may also be used to create desktop apps, what then? Can I export .exe file with Python code or what?
Any links with content describing my concerns are welcome!
Explanation / Answer
When I work with HTML, PHP, etc., I simply write code, put it inside .html or .php file and double click this file. Then my code runs.
But how does Python work?
Exactly the same way.
Double-click a .py file and your code runs.
I'm working inside Eclipse or Python command line and I can run this code, but what if I want make website with Python for example?
You usually use Apache to host a web site. You usually use mod_wsgi to run Python inside Apache. This is exactly like using mod_php to run PHP inside Apache.
Exactly the same.
I don't think it's like I put .py file on my server,
False. You do put .py files on your server. How else could it possibly work?
so what I need to do? I understand I need to install Python on my webserver through some server command line (I've never used it, but I will find some tutorials day I will need it) but what's next?
You need mod_php to run PHP. You need mod_wsgi to run Python.
So if I made some website with Python, then my user will see my index.py file when he comes to my server?
You could do that. It would be fairly silly, however.
Usually, you set up mod_wsgi so that it executes your .py file, and your .py file creates the HTML page.
This parallels the way mod_php executes the .php file to create an HTML page.
Or can I use Python code inside html like with php wrapped inside <?php ?>?
No. You put the HTML inside the Python.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.