Re: [google-appengine] Problems will google app engine webapp or YAML file????????(python)

2015-08-28 Thread 'Alex Martelli' via Google App Engine
In main.py, just change the line

webapp = webapp2.WSGIApplication([

into

app = webapp2.WSGIApplication([


Alex



On Thu, Aug 27, 2015 at 8:34 PM, Ale P zonepeli...@gmail.com wrote:

 I have been using google app engine for a udacity class. I been trying to
 get some code to work but when I showed the website my python code they
 said nothing was wrong with it. They said I should look and fix or change
 the variable I call webapp into app and do the same for the YAML file.
 Tell me how to fix or change the webapp variable and the YAML file, so i
 can run my code on google app engine.
 Here is mu YAML file:
 application: engineapp
 version: 1
 runtime: python27
 api_version: 1
 threadsafe: yes

 handlers:
 - url: /favicon\.ico
   static_files: favicon.ico
   upload: favicon\.ico

 - url: .*
   script: main.app

 libraries:
 - name: webapp2
   version: 2.5.2


 Here is my main.py (webapp variable) :

 import webapp2
 from cgi import escape

 html = 
 form method=post
   What is your birthday?
   br
   labelMonth: input type=text name=m
 value=%(input_month)s/label
   labelDay: input type=text name=d value=%(input_day)s/label
   labelYear: input type=text name=y value=%(input_year)s/label
   div style=color: red%(error_msg)s/div
   brbr
   input type=submit
 /form
 

 class RootPageHandler(webapp2.RequestHandler):
 months = [
 'January', 'February', 'March', 'April', 'May', 'June', 'July'
 'August', 'September', 'October', 'November', 'December'
 ]

 months_abbr = dict((month[:3].lower(), month) for month in months)

 def valid_month(self, user_input = None):
 if type(user_input) == unicode:
 test_value = user_input[:3].lower()
 if test_value in self.months_abbr:
 return self.months_abbr[test_value]
 return ''

 def valid_day(self, user_input = None):
 if type(user_input) == unicode and user_input.isdigit():
 number = int(user_input)
 if (number  0 and number  32):
 return user_input
 return ''

 def valid_year(self, user_input = None):
 if type(user_input) == unicode and user_input.isdigit():
 number = int(user_input)
 if (number = 1900 and number = 2020):
 return user_input
 return ''


 def write_html(self, error = '', month = '', day = '', year = ''):
 self.response.out.write(html % {
 'error_msg': error,
 'input_month': escape(month, quote = True),
 'input_day': escape(day, quote = True),
 'input_year': escape(year, quote = True)
 })


 def get(self):
 self.write_html()


 def post(self):
 month_input = self.request.get('m')
 day_input = self.request.get('d')
 year_input = self.request.get('y')

 month_valid = self.valid_month(month_input)
 day_valid = self.valid_day(day_input)
 year_valid = self.valid_year(year_input)

 if not (month_valid and day_valid and year_valid):
 self.write_html(error = That doesn't look like a valid
 birthday,
 month = month_valid, day = day_valid, year = year_valid)
 else:
 self.redirect('/thanks')

 class ThanksPageHandler(webapp2.RequestHandler):
 def get(self):
 self.response.out.write('validated')


 webapp = webapp2.WSGIApplication([
 ('/', RootPageHandler),
 ('/thanks', ThanksPageHandler)
 ], debug=True)

 --
 You received this message because you are subscribed to the Google Groups
 Google App Engine group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to google-appengine+unsubscr...@googlegroups.com.
 To post to this group, send email to google-appengine@googlegroups.com.
 Visit this group at http://groups.google.com/group/google-appengine.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/google-appengine/9a7e6dda-6f94-4092-95e3-8b3dda8bef78%40googlegroups.com
 https://groups.google.com/d/msgid/google-appengine/9a7e6dda-6f94-4092-95e3-8b3dda8bef78%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/CAE46Be-tEPxbM%3D5BCJCwYGjtMWZJRLBLbQ50AEHi75VF4OwBiA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Problems will google app engine webapp or YAML file????????(python)

2015-08-27 Thread Ale P
I have been using google app engine for a udacity class. I been trying to 
get some code to work but when I showed the website my python code they 
said nothing was wrong with it. They said I should look and fix or change 
the variable I call webapp into app and do the same for the YAML file. Tell 
me how to fix or change the webapp variable and the YAML file, so i can run 
my code on google app engine.
Here is mu YAML file:
application: engineapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: 2.5.2


Here is my main.py (webapp variable) :

import webapp2
from cgi import escape

html = 
form method=post
  What is your birthday?
  br
  labelMonth: input type=text name=m value=%(input_month)s/label
  labelDay: input type=text name=d value=%(input_day)s/label
  labelYear: input type=text name=y value=%(input_year)s/label
  div style=color: red%(error_msg)s/div
  brbr
  input type=submit
/form


class RootPageHandler(webapp2.RequestHandler):
months = [
'January', 'February', 'March', 'April', 'May', 'June', 'July'
'August', 'September', 'October', 'November', 'December'
]

months_abbr = dict((month[:3].lower(), month) for month in months)

def valid_month(self, user_input = None):
if type(user_input) == unicode:
test_value = user_input[:3].lower()
if test_value in self.months_abbr:
return self.months_abbr[test_value]
return ''

def valid_day(self, user_input = None):
if type(user_input) == unicode and user_input.isdigit():
number = int(user_input)
if (number  0 and number  32):
return user_input
return ''

def valid_year(self, user_input = None):
if type(user_input) == unicode and user_input.isdigit():
number = int(user_input)
if (number = 1900 and number = 2020):
return user_input
return ''


def write_html(self, error = '', month = '', day = '', year = ''):
self.response.out.write(html % {
'error_msg': error,
'input_month': escape(month, quote = True),
'input_day': escape(day, quote = True),
'input_year': escape(year, quote = True)
})


def get(self):
self.write_html()


def post(self):
month_input = self.request.get('m')
day_input = self.request.get('d')
year_input = self.request.get('y')

month_valid = self.valid_month(month_input)
day_valid = self.valid_day(day_input)
year_valid = self.valid_year(year_input)

if not (month_valid and day_valid and year_valid):
self.write_html(error = That doesn't look like a valid 
birthday,
month = month_valid, day = day_valid, year = year_valid)
else:
self.redirect('/thanks')

class ThanksPageHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write('validated')


webapp = webapp2.WSGIApplication([
('/', RootPageHandler),
('/thanks', ThanksPageHandler)
], debug=True)

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/9a7e6dda-6f94-4092-95e3-8b3dda8bef78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.