回答編集履歴

3

ケアレスミスの記述

2017/05/05 14:14

投稿

kamakiri
kamakiri

スコア13

test CHANGED
@@ -161,3 +161,9 @@
161
161
  >>>The browser (or proxy) sent a request that this server could not understand.
162
162
 
163
163
  こうなった
164
+
165
+
166
+
167
+ この時点でhtmlのmethodがmethoになってたっぽい・・・
168
+
169
+ 細かい所気をつけよう

2

変更点の追加

2017/05/05 14:14

投稿

kamakiri
kamakiri

スコア13

test CHANGED
@@ -107,3 +107,57 @@
107
107
 
108
108
 
109
109
  こうかな・・・?
110
+
111
+
112
+
113
+
114
+
115
+ ↑をこうした
116
+
117
+ ```python
118
+
119
+ @app.route('/image/<int:image_id>/classify', methods=['GET','POST'])
120
+
121
+ @login_required
122
+
123
+ def classify_images(image_id):
124
+
125
+ image = Image.query.get(image_id)
126
+
127
+ image.good = 0
128
+
129
+ image.normal = 0
130
+
131
+ image.bad = 0
132
+
133
+ if request.form['good']:
134
+
135
+ image.good = 1
136
+
137
+ if request.form['normal']:
138
+
139
+ image.normal = 1
140
+
141
+ if request.form['bad']:
142
+
143
+ image.bad = 1
144
+
145
+ db.session.add(image)
146
+
147
+ db.session.commit()
148
+
149
+ flash('New classification was successfully posted')
150
+
151
+ return redirect(url_for('show_image'))
152
+
153
+ ```
154
+
155
+
156
+
157
+ そしたら、
158
+
159
+ >>>BAD Request
160
+
161
+ >>>The browser (or proxy) sent a request that this server could not understand.
162
+
163
+ こうなった

1

綺麗にした

2017/05/05 13:41

投稿

kamakiri
kamakiri

スコア13

test CHANGED
@@ -61,3 +61,49 @@
61
61
 
62
62
 
63
63
  こんな感じか・・・?
64
+
65
+
66
+
67
+
68
+
69
+ ```python
70
+
71
+ @app.route('/classify', methods=['GET','POST'])
72
+
73
+ @login_required
74
+
75
+ def classify_images(image_id):
76
+
77
+ image = Image.query.get(image_id)
78
+
79
+ image.good = 0
80
+
81
+ image.normal = 0
82
+
83
+ image.bad = 0
84
+
85
+ if request.form['good']:
86
+
87
+ image.good = 1
88
+
89
+ if request.form['normal']:
90
+
91
+ image.normal = 1
92
+
93
+ if request.form['bad']:
94
+
95
+ image.bad = 1
96
+
97
+ db.session.add(image)
98
+
99
+ db.session.commit()
100
+
101
+ flash('New classification was successfully posted')
102
+
103
+ return redirect(url_for('show_image'))
104
+
105
+ ```
106
+
107
+
108
+
109
+ こうかな・・・?