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 ...}
This post relates to this question
模板添加到
下面{% 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 %}
答案 0 :(得分:0)
表单中未指定任何操作。在模板的表单标记中,您应添加action = Url / Matching / BaseCourt。
答案 1 :(得分:0)
在我的模板中,<form action...
之前是一个开放标记:<br
修复后,表单正在响应。