import webapp2
from views import MainPageCourt, CreateCourt, DeleteCourt, EditCourt, Listbox, \
MainPage, CreateLocation, DeleteLocation, EditLocation, Unexpected, \
Schedule
app = webapp2.WSGIApplication([
('/', MainPage),
('/unexpected', Unexpected),
('/listbox', Listbox),
('/read/([\w]+)', MainPageCourt),
('/create/([\w]+)', CreateCourt),
('/createlocation/([\w]+)', CreateLocation),
('/schedule/([\w]+)/([\w]+)', Schedule),
('/editlocation/([\w]+)', EditLocation),
('/deletelocation/([\w]+)', DeleteLocation),
('/edit/([\w]+)/([\d]+)', EditCourt),
('/delete/([\w]+)/([\d]+)', DeleteCourt)
],
debug=True)
application: scheduler
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /static
static_dir: static
- url: /create|schedule|createlocation|editlocation|deletelocation|edit|delete/.*
script: main.app
login: required
- url: /.*
script: main.app
libraries:
- name: jinja2
version: latest
- name: markupsafe
version: latest
builtins:
- remote_api: on
对于我的初级课程class MainPageCourt(BaseHandler):
,def post() 代码永远不会被读取,我不知道为什么。当我按下模板上的提交按钮时,没有任何反应,gae 日志中也没有任何反应。我想知道问题是否是我希望 post() 和 get() 通过转到同一页面 read.html 以相同的方式“完成”?这是一个问题还是我在寻找错误的方式和错误的地方来解决我的问题?如果是问题所在,有什么简单的解决方法?
下面的第一行是 post(),第二行是 MainPageCourt 的 get()。
return webapp2.redirect("/read/%s" % location_id)
self.render_template('read.html', {'courts': courts,'location': location, ... etc ...}
下面添加的模板
{% extends "base.html" %}
{% block content %}
<p> You can start over at the beginning <a href="/">here.</a> </p>
<p class="schedule" style="width: 850px;">
<big>{{ location.moreinfo}} </big> <br /
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="ID" value="{{ location_id }}"></input>
<input type="hidden" name="weekday" value="{{ weekday }}"></input>
<input type="hidden" name="nowweekday" value="{{ nowweekday }}"></input>
<input type="hidden" name="month" value="{{ month }}"></input>
<input type="hidden" name="month" value="{{ nowmonth }}"></input>
<input type="hidden" name="day" value="{{ day }}"></input>
<input type="hidden" name="year" value="{{ year }}"></input>
<input type="hidden" name="startTime" value="{{ startTime }}"></input>
<input type="hidden" name="endTime" value="{{ endTime }}"></input>
{% for name in names %}
<input type="hidden" name="court" value="{{ name }}"></input>
{% endfor %}
<h1>{{ weekday }}, {{ month }} {{ day }}, {{ year }} at {{ location_id }} {{ location.venue }}</h1> <br />
Make a reservation by (1) filling out table fields and then (2) clicking "submit".
<div id="inputdata">
<input type="submit" value=submit />
</div>
<table border="1" cellpadding="2"
cellspacing="0" class="sortable" id="unique-id" align="center">
<thead>
<tr>
<td>Time</td>
{% for name in names %}
<td>{{ name }}</td>
{% endfor %}
</tr></thead>
<tbody>
{% for time in times %}
<tr>
<td >
{{ time[2] }}
</td>
{% for i in range(names|count) %}
<td>
{{ time[3+i] }}
</td>
{% endfor %}
{% endfor %}
</tr>
</tbody>
</form>
</table>
<br />
{% endblock content %}