回答編集履歴
3
ケアレスミスの記述
answer
CHANGED
@@ -79,4 +79,7 @@
|
|
79
79
|
そしたら、
|
80
80
|
>>>BAD Request
|
81
81
|
>>>The browser (or proxy) sent a request that this server could not understand.
|
82
|
-
こうなった
|
82
|
+
こうなった
|
83
|
+
|
84
|
+
この時点でhtmlのmethodがmethoになってたっぽい・・・
|
85
|
+
細かい所気をつけよう
|
2
変更点の追加
answer
CHANGED
@@ -52,4 +52,31 @@
|
|
52
52
|
return redirect(url_for('show_image'))
|
53
53
|
```
|
54
54
|
|
55
|
-
こうかな・・・?
|
55
|
+
こうかな・・・?
|
56
|
+
|
57
|
+
|
58
|
+
↑をこうした
|
59
|
+
```python
|
60
|
+
@app.route('/image/<int:image_id>/classify', methods=['GET','POST'])
|
61
|
+
@login_required
|
62
|
+
def classify_images(image_id):
|
63
|
+
image = Image.query.get(image_id)
|
64
|
+
image.good = 0
|
65
|
+
image.normal = 0
|
66
|
+
image.bad = 0
|
67
|
+
if request.form['good']:
|
68
|
+
image.good = 1
|
69
|
+
if request.form['normal']:
|
70
|
+
image.normal = 1
|
71
|
+
if request.form['bad']:
|
72
|
+
image.bad = 1
|
73
|
+
db.session.add(image)
|
74
|
+
db.session.commit()
|
75
|
+
flash('New classification was successfully posted')
|
76
|
+
return redirect(url_for('show_image'))
|
77
|
+
```
|
78
|
+
|
79
|
+
そしたら、
|
80
|
+
>>>BAD Request
|
81
|
+
>>>The browser (or proxy) sent a request that this server could not understand.
|
82
|
+
こうなった
|
1
綺麗にした
answer
CHANGED
@@ -29,4 +29,27 @@
|
|
29
29
|
|
30
30
|
```
|
31
31
|
|
32
|
-
こんな感じか・・・?
|
32
|
+
こんな感じか・・・?
|
33
|
+
|
34
|
+
|
35
|
+
```python
|
36
|
+
@app.route('/classify', methods=['GET','POST'])
|
37
|
+
@login_required
|
38
|
+
def classify_images(image_id):
|
39
|
+
image = Image.query.get(image_id)
|
40
|
+
image.good = 0
|
41
|
+
image.normal = 0
|
42
|
+
image.bad = 0
|
43
|
+
if request.form['good']:
|
44
|
+
image.good = 1
|
45
|
+
if request.form['normal']:
|
46
|
+
image.normal = 1
|
47
|
+
if request.form['bad']:
|
48
|
+
image.bad = 1
|
49
|
+
db.session.add(image)
|
50
|
+
db.session.commit()
|
51
|
+
flash('New classification was successfully posted')
|
52
|
+
return redirect(url_for('show_image'))
|
53
|
+
```
|
54
|
+
|
55
|
+
こうかな・・・?
|