import webapp2
from google.appengine.ext import db
from google.appengine.ext.webapp import template
class Convert(db.Model):
user = db.StringProperty(required=True)
USD = db.FloatProperty(required=True)
SR = db.FloatProperty()
class MainHandler(webapp2.RequestHandler):
def get(self):
conversion=db.GqlQuery('SELECT * FROM Convert')
values={'conversion':conversion}
self.response.out.write(template.render('main.html',values))
def post(self):
prog= Convert(user=(self.request.get('userName')),USD=((float)self.request.get('currency'))),SR=((float)(self.request.get('currency')*3.75)))
prog.put()
self.redirect('/')
app = webapp2.WSGIApplication([('/', MainHandler)], debug=True)
来自我的main.html的代码
<tr><td>{% for a in conversion%}
<div align="right" lang="ar"><font size="+1" color="#000000"><strong><font color="#009999">{{a.user}}أدخل:</font>
{{a.USD}}<font color="#990000">م</font> = {{a.SR}}{% endfor %}
</td></tr>
<tr><td>
<form action="" method="post" accept-charset="utf-8">
<p align="right" dir="rtl"><strong><font color="#003366">أدخل الدولار الأمريكي:</font></strong><input type="text" name="currency" value="" id="currency"></input></p>
<p align="right" dir="rtl"><strong><font color="#003366">الرجـاء إدخــال اسمـك:</font></strong><input type="text" name="userName" value="" id="userName"></input></p>
<p align="right"><input type="submit" value="تحويل العملة"></input></p>
</form>
</td></tr>