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() コードが読み取られず、その理由がわかりません。テンプレートの送信ボタンを押しても何も起こらず、ゲーログに反応がありません。問題は、post() と get() の両方を同じページ read.html に移動して同じように「終了」させたいということでしょうか? それは問題ですか、それとも私の問題を間違った方法で間違った場所で探していますか? それが問題である場合、簡単な回避策は何ですか?
以下の 1 行目は post() 用で、2 行目は 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 %}