How to set up XAMPP to run Python programs and php on your own computer. SQL works also. Only tested on windows 10.All programs can be run through localhost in browser and files stored in htdocs directory in xampp.
Xampp Version 5.6.30
Python.3.6.1
Link to Python
Link to XAMPP
Should be the same versions as mine in order to work.
Make sure to save Python as C:Python3.6 using custom installation.First line of your program must direct to where python.exe is installed.Mine is #!C:/Python3.6/python.exe .You must use parenthesis with print.
Instructions:
__________________________________________________________________
1.Install xampp and python, make sure to remember the location where everything is installed.Mine are in 1 folder.
2.When both are installed, run XAMPP.
3.add test files to htdocs mine are downloadable.
4.Open the httpd.conf file in apache by clicking config but do not start apache yet.
6. Look for AddHandler cgi-script .cgi .pl .asp and add .py to it
7.Start apache
8. open a browser, type localhost and go to it. This is your homepage.
9. To run your files type localhost/ enter in name of file. eg
localhost/hello.py
10. That’s it, it should work. Just make sure to have correct shebang on top of python files which shows the location of where python.exe is. Mine is #!C:/Python3.6/python.exe
11. You now should add passwords and run it offline if needed.
12.Python files need print(“content-type: text/htmlnn” ) below shebang in order to work.
my httpd file :
Python test program :
Php test program :
Program to run in idle to find path for shebang. Just add #! before it and double check it says python or python.exe if not just change it to the result of idle program.
Nguồn: https://codeigniterbrasil.com
Xem thêm bài viết khác: https://codeigniterbrasil.com/lap-trinh-php/
Xem thêm Bài Viết:
- MDM là gì??? – Làm thế nào để tắt được MDM trên Macbook | Mẹo Vặt Macbook
- Người lao động nghỉ bị trừ lương || Tư vấn luật lao động
- Learn Emmet In 15 Minutes – Double Your HTML Coding Speed
- Giang Hồ Thanh Toán Nhau Trên Phố – Tập 4 – Giang Hồ Bắn Giết Nhau Trên Đường | Big Bang
- Lập trình Android A-Z – Bài 159: Fragment Create and add XML
Suru_Kro
May 2, 2020Internal server error in python?? End of script output header before .py file??
Are you running XAMPP -server?
Want to solve… Then go there https://youtu.be/NYevQUGexRo
Shubhamkar Joshi
May 2, 2020couldn't create child process: 720005
Im getting this error. Culd you help?
Goldensparrow Mobile
May 2, 2020thnaks
Ageim
May 2, 2020it just show the code
#!c:/Python3.6/python.exe
print("Content-type: text/html")
print("""
<title> a </title>
<h1> hi</h1>
hello
""")
SHADOW
May 2, 2020Working
Mithzy Nelson
May 2, 2020You saved my butt!! Thanks!!
Shivam Singh
May 2, 2020Bro It Works! Only I need to replace the path '#!C:/Python3.6/python.exe' to '#!C:UsersroxxshivamsinghAppDataLocalProgramsPythonPython37python.exe' it depends upon where your python interpreter is install check properly and copy path and paste it on the top of the page in comment using '!' symbol…
Bruno Souza
May 2, 2020it doesnt working
prajwal kumar
May 2, 2020but mysql module error is cmng fr me…..rest it works for me.
Steven Choo
May 2, 2020if Python3.6.1 does not work, then try to download Python2.7.15 (Window users).
I solved my problem by doing this step.
chanchal dhingra
May 2, 2020not able follow after localhost
Junaid khan
May 2, 2020Working Great 🙂 Even on newer version.
Kindly I have a quaestion, How can I run that .py file from within the php file?
Peter Bennett
May 2, 2020Ok guys, a couple of things you should remember…. when telling the script where your python file is located, make sure you use FORWARD slashes not back slashes, and make sure you point to the .exe not the root directory!! Worked for me, actually impressed at how simple it is!!! If this works when I deploy, I will be even happier!
TrashPanda
May 2, 2020works thanks!
MImran Khan
May 2, 2020Not working
Mostafa Abu Gheda
May 2, 2020What is the name of this track in the video ? 😀
RoadracerSLO
May 2, 2020tnx mate, just what I needed 🙂
Martin Brant
May 2, 2020Hi, any chance you could give a link to your Python code? Is this Python 2 or 3? Thanks
Pandula Perera
May 2, 2020Great!!!
FIRDOUS BHAT
May 2, 2020how come dude ? Simply you placing python program in htdocs and it works ?
Kapil Saran
May 2, 2020thxx man
radika watterson
May 2, 2020hey jason , i'm from indonesia. i can't running my python on my lampp. do you have any tutorial ?
Atul Varshney
May 2, 2020Hey Jason Cheung.. your video does work and it's appreciable.. but I'm stuck in running python script. Actually if i run simple python script like "Hello Python"with html tag then it does work,if i used only python script code that doesn't work , actually i want to get current URL using python script then how to do this. first of fall let me tell you. I'm getting the "Server Error!"
So finally i just wanna say how to write any python script. because previous script has with html tag not python coding at all. So Please get me the solution. I hope you are able get me .. what i wanna ask?