2012-03-10 85 views
1

我是一名使用GAE的初学者,我试图在GAE上部署一个测试。GAE为什么没有检测到我的表单页面?

这样做的目的是制作一个表单,用户输入年份,月份和日期,然后它将生成属于该日期的星期几。

它工作正常,当我在localhost:8080使用“dev_appserver.py。”尝试它时,但我将它部署到GAE后,找不到页“/ form”。

这是链接到应用程序:http://yao-webapp1.appspot.com/

我猜它可能有事情做与我的app.yaml文件,但我不知道。 如果它有帮助,所有三个文件,包括bottle.py都在一个文件夹中。

编辑*当我使用GAE启动器的GUI版本时,表单页面也不工作。

这里是我的代码:

main.py

""" 
Author: Yao Jiang 
Filename: main.py 
Copyright (c) 2012 All rights reserved. 
""" 

import bottle 
from google.appengine.ext.webapp import util 
from bottle import route, template, request 
from datetime import date 

@route('/') 
def hello(): 
    return "Hello New World!" 

@route('/form') 
def userDate(): 
    if request.GET.get('userDate', '').strip(): 
     dayOfWeek = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; 
     year = request.GET.get('year'); 
     month = request.GET.get('month'); 
     day = request.GET.get('day'); 

     userDate = date(int(year), int(month), int(day)); 
     choice = dayOfWeek[date.weekday(userDate)]; 

     return "<center><h1>The day of the week for %s is %s.</h1></center>" % (userDate.strftime("%b %d, %Y"), choice); 
    else: 
     return template('form.tpl'); 

util.run_wsgi_app(bottle.default_app()) 

的app.yaml

application: yao-webapp1 
version: 1 
api_version: 1 
runtime: python 

handlers: 
- url: .* 
    script: main.py 

form.tpl

%# template for the date form 
<html> 
    <body> 
     <p>FIND THE DAY OF THE WEEK</p> 
     <form action="/form" method="GET"> 
     Year: <input type="text" size="10" maxlength="10" name="year"> 
     Month: <input type="text" size="10" maxlength="10" name="month"> 
     Day: <input type="text" size="10" maxlength="10" name="day">   
     <input type="submit" name="userDate" value="submit"> 
     </form> 
    </body> 
</html> 

回答

相关问题