:: gedit
--> ใช้เขียนแก้ไขโค้ด โดยเมื่อบันทึกต้องระบุชนิดไฟล์ เช่น asd.py, xyz.html
:: Python -m SimpleHTTPServer
--> browser ที่แสดงผล server แบบนี้จะ render HTML ได้ แต่ไม่สามารถ render code python คือไม่แสดงผลลัพธ์ของโค้ด
--> เมื่อจะแก้ไขผลลัพธ์ต้องแก้ไขที่โค้ด HTML
:: Python -m CGIHTTPServer
--> เรียกใช้ code python แล้วเอาผลลัพธ์ส่งกลับไปแสดงบน Browser
--> สามารถแก้ไขโค้ดได้ที่ python เลย ใช้เหมือน html
--> บันทึก code .cgi file เมื่อไป render บน server ต้องกำหนดค่า excute file
: click right file -> Properties -> excute -> T Allow excuting file as program
--> ต้องเปิดโดยการพิมพ์ชื่อ directory หลัง folder cgi-bin
Code CGI :
#!/usr/bin/python print"content-type: text/html\n\n" print"<head>" print"<title>Lecture</title>" print"<style type = 'text/css'>" print".style1{font-size: xx-large;"+"font-weight:bold;"+"color: #CC33FF;"+"}"+"body{background-color:#FFCCFF}" print"</style>" print"</head>" print"<body>" print"<b>"+"<p align =\"center\"><spen class=\"style1\">Lecture Date:011215</span></p>"+"</b></br>\n" print"<p><strong>Ubuntu Linux </strong>:: free ware/open source </p>\n" print"<p><strong>Browser </strong></br> :: Client - Server </br> :: Browser Render HTML Language</br> :: python -m SimpleHTTPServer [serving HTTP on 0.0.0.0 port 8000]</br> : http://0.0.0.0:8000</br> : Browser isn't render python code</p>\n" print"</br></br><p align=\"center\"><img src=\"http://www.picgifs.com/clip-art/cartoons/snoopy/clip-art-snoopy-346942.jpg\" alt=\"Simple\" style=\"width:212px;height:300px\"></img></p></br>" print"</body>\n"" print""+"Lecture Date:011215
Browser render code :
ไม่มีความคิดเห็น:
แสดงความคิดเห็น