หัดใช้ nsurl
posted on 10 Dec 2009 19:31 by xnanoob in Otherดีค่ะ
ตอนนี้หัดดึง data จาก url ใน google app engine
- http://iphone57pixel.appspot.com/ ตัวอย่างจาก app id นี้อะค่ะ
โดยใช้ class nsurl ดึงข้อมูลออกมา
จบแระค่า บายค่ะ
ดีค่ะ
ตอนนี้หัดดึง data จาก url ใน google app engine
- http://iphone57pixel.appspot.com/ ตัวอย่างจาก app id นี้อะค่ะ
โดยใช้ class nsurl ดึงข้อมูลออกมา
จบแระค่า บายค่ะ
หัดทำ python โดยทำฟอร์มแบบง่ายให้เอาค่าจาก textbox มาบวกกานนะค่ะ
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write("""
<html>
<body>
<form action="/result" method="post">
<div><input type="text" name="number_a"></input></div>
<div><input type="text" name="number_b"></input></div>
<div><input type="submit" value="done"></div>
</form>
</body>
</html>""")
class add(webapp.RequestHandler):
def post(self):
self.response.out.write('<html><body>result:<pre>')
self.response.out.write(int(cgi.escape(self.request.get('number_a'))) +
int(cgi.escape(self.request.get('number_b'))))
self.response.out.write('</pre></body></html>')
application = webapp.WSGIApplication(
[('/', MainPage),
('/result', add)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
ถ้าเขียน python แล้วอยากจะ convert string to int
ต้องใช้ function int ในการ convert
ทดสอบการทำงานได้ที่
http://helloworldgaaksoft.appspot.com/ นะค่ะ
ดีค่ะ วันนี้หยุด เลยอยากลองเขียน python แต่ ..
python มันคืออะไร ตับไตไส้พุง .. ยังไม่รู้เลยยย
ก็ลองมั่วๆ จากตัวอย่างของฝรั่งก่อน
helloworld.py print 'Content-Type: text/plain' print '' print 'Hello, world!'
app.yaml application: helloworld version: 1 runtime: python api_version: 1 handlers: - url: /.* script: helloworld.py
run ได้แต่ไม่ค่อยเข้าใจเลย
จบแระ

ลองอ่านเดะ
เย้ .. ดีใจจัง
iciagalert สถานนะเปลี่ยน waiting for review เป็น in review แล้ว
จบแล้ว