为什么GAE没有检测到我的表单页面? [英] why is GAE not detecting my form page?

查看:81
本文介绍了为什么GAE没有检测到我的表单页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名使用GAE的初学者,我正在尝试为GAE部署一个测试。



这个目标是让用户输入一个表单年,月,日,那么它会生成属于该日期的星期几。



当我在localhost:8080中使用 dev_appserver.py,但在将其部署到GAE后,未找到页面/ form。



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



<我猜这可能与我的app.yaml文件有关,但我不确定。
如果它对任何东西都有帮助,包括bottle.py在内的所有三个文件都在一个文件夹中。



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



以下是我的代码:

main.py

 
作者:姚江
文件名:main.py
版权所有(c)2012保留所有权利


从google.appengine.ext.webapp导入瓶子
导入util $ b $从瓶子导入路线,模板,请求
从datetime导入日期

@route('/')
def hello():
returnHello New World!

@route('/ form')
def userDate():
如果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>%s的星期几是%s。< / h1>< / center> %(userDate.strftime(%b%d,%Y),选择);
else:
返回模板('form.tpl');

util.run_wsgi_app(bottle.default_app())

app.yaml

 应用程序:yao-webapp1 
版本:1
api_version:1
运行时:python

处理程序:
- url:。*
script:main.py

form.tpl

 %#日期格式的模板
< html>
< body>
< p>寻找本周的日子< / p>
< form action =/ formmethod =GET>
年:< input type =textsize =10maxlength =10name =year>
月:< input type =textsize =10maxlength =10name =month>
日:< input type =textsize =10maxlength =10name =day>
< input type =submitname =userDatevalue =submit>
< / form>
< / body>
< / html>


解决方案

/ form是app引擎上的保留url:< a href =http://code.google.com/appengine/docs/python/config/appconfig.html#Reserved_URLs =nofollow> http://code.google.com/appengine/docs/python/ config / appconfig.html#Reserved_URLs



选择其他路径,它应该可以正常工作。


I'm a TOTAL beginner using GAE and I am trying to deploy a test to GAE.

The objective of this is to make a form where a user enters year, month, and day, then it will generate the day of the week that belongs to that date.

It works fine when I tried it in localhost:8080 using "dev_appserver.py .", but after I deployed it to GAE, the page "/form" is not found.

This is the link to the app: http://yao-webapp1.appspot.com/

I'm guessing that it probably has something to do with my app.yaml file, but I'm not sure. If it helps with anything, all three files including bottle.py is all in one folder.

edit* also when I used the GUI version of GAE launcher, the form page does not work neither.

Here are my codes:

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>

解决方案

/form is a reserved url on app engine: http://code.google.com/appengine/docs/python/config/appconfig.html#Reserved_URLs

Pick a different path and it should work fine.

这篇关于为什么GAE没有检测到我的表单页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆