質問編集履歴

4

追加

2021/12/18 08:11

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -106,13 +106,15 @@
106
106
 
107
107
  @app.route('/result', methods=['GET', 'POST'])
108
108
 
109
- name = request.form["name"]
109
+ def result():
110
110
 
111
- num = request.form["num"]
111
+ name = request.form["name"]
112
112
 
113
- ui = nn(name,num)
113
+ num = request.form["num"]
114
114
 
115
+ ui = nn(name,num)
116
+
115
-                 return render_template('index.html',ui=ui)
117
+ return render_template('index.html',ui=ui)
116
118
 
117
119
 
118
120
 

3

追加

2021/12/18 08:11

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Herokuデプロしたい
1
+ ローカル動いたファルをサーバーで動かすと405エラーになる
test CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
 
4
4
 
5
+ ロリポップFTPでファイルをアップロードしましたが、ローカル環境では動いたファイルがエラーになります。
6
+
7
+
8
+
5
- jupyterで制作した.pyをHerokuでデプロイしたいです。
9
+ HTMLからPYthonへ受け渡時に405エラーが表示されます
6
10
 
7
11
 
8
12
 
@@ -13,10 +17,6 @@
13
17
 
14
18
 
15
19
  ### 発生している問題・エラーメッセージ
16
-
17
-
18
-
19
- ターミナルでpython index.py後、http://localhost:5000/の結果です
20
20
 
21
21
  ```
22
22
 
@@ -34,190 +34,6 @@
34
34
 
35
35
  ### 該当のソースコード
36
36
 
37
-
38
-
39
- ```Procfile
40
-
41
- web: gunicorn -b 0.0.0.0:$PORT app:app
42
-
43
- ```
44
-
45
- ```README
46
-
47
- # Introduction
48
-
49
- This is a demo project for playing with Heroku!
50
-
51
- For simplicity, I am using quite simple Flask app, so if you would like to modify the code, it's totally fine! I mean, I would like to encourage to it.
52
-
53
- But before, that I would recommend you to try following this project firstly!
54
-
55
- Tnen convert it into your style later!
56
-
57
-
58
-
59
- ## Prerequiresites
60
-
61
- Since I would like you to enjoy your life with Heroku and showing your achievement ASAP, I have skipped the explanaiton on the code, especially flask part.
62
-
63
- So if it's needed, please familiarise yourself with Flask.
64
-
65
-
66
-
67
- Flask Official Doc
68
-
69
- http://flask.pocoo.org/docs/1.0/quickstart/
70
-
71
-
72
-
73
-
74
-
75
- ## Python Version
76
-
77
- 3.6.* or 2.7.*
78
-
79
-
80
-
81
- ## Agenda
82
-
83
- 1. What is Heroku?
84
-
85
- 2. Registration(Sign up)
86
-
87
- 3. Installation of CLI tool
88
-
89
- 4. Deployment
90
-
91
-
92
-
93
- ## 1. What is Heroku?
94
-
95
- Heroku is a cloud platform that lets companies build, deliver, monitor and scale apps — we're the fastest way to go from idea to URL, bypassing all those infrastructure headaches.
96
-
97
-
98
-
99
- ## 2. Registration(Sign up)
100
-
101
- Check this link and fill the blank.
102
-
103
- https://signup.heroku.com/
104
-
105
-
106
-
107
- ## 3. Installation of CLI tool
108
-
109
- Using the cli tool, we have an access to Heroku service from our terminal/CMD.
110
-
111
- Link: https://devcenter.heroku.com/articles/heroku-cli
112
-
113
- So pick one according to your machine.
114
-
115
-
116
-
117
- ## 4. Deployment
118
-
119
- In this section, I will put some comment on between the line of the bash command,
120
-
121
- so check them a bit carefully!
122
-
123
-
124
-
125
- ``bash
126
-
127
- # first you need to login!
128
-
129
- $ heroku login
130
-
131
- # <outcome>
132
-
133
- # Email: ??
134
-
135
- # Password: ??
136
-
137
- # Logged in as : your-user-name
138
-
139
-
140
-
141
- # get this repo
142
-
143
- $ git clone https://github.com/Rowing0914/Heroku_training_flask.git
144
-
145
- # move to the directory
146
-
147
- $ cd Heroku_training_flask
148
-
149
- # test on the local machine!
150
-
151
- $ python app.py
152
-
153
- # Be sure that this works properly!
154
-
155
- ``
156
-
157
-
158
-
159
- By now you should see the images below by hitting your localhost:5000
160
-
161
- ![im1](https://github.com/Rowing0914/Heroku_training_flask/blob/master/images/im1.png)
162
-
163
-
164
-
165
- then, let's move on to deploy it!
166
-
167
-
168
-
169
- ``bash
170
-
171
- # this will assign the domain_name to your app
172
-
173
- $ heroku create
174
-
175
- ``
176
-
177
- ![im3](https://github.com/Rowing0914/Heroku_training_flask/blob/master/images/im3.png)
178
-
179
-
180
-
181
- ``bash
182
-
183
- # deploy!!
184
-
185
- $ git push heroku master
186
-
187
- ``
188
-
189
-
190
-
191
- ![im4](https://github.com/Rowing0914/Heroku_training_flask/blob/master/images/im4.png)
192
-
193
-
194
-
195
- bash
196
-
197
- $ heroku open
198
-
199
-
200
-
201
- DONE!
202
-
203
-
204
-
205
- ![im2](https://github.com/Rowing0914/Heroku_training_flask/blob/master/images/im2.png)
206
-
207
-
208
-
209
- Thank you!
210
-
211
- ```
212
-
213
- ```requirements
214
-
215
- Flask
216
-
217
- gunicon
218
-
219
- ```
220
-
221
37
  ```layouthtml
222
38
 
223
39
  <!DOCTYPE html>
@@ -234,7 +50,7 @@
234
50
 
235
51
  <body>
236
52
 
237
- <form method = "POST" action="index.py">
53
+ <form method = "POST" action="/result">
238
54
 
239
55
  <label>名前<input type="text" value="" size="30" name="name"></label>
240
56
 
@@ -254,7 +70,9 @@
254
70
 
255
71
  ```indexhtml
256
72
 
257
- {% extends "layout.html" %} {% block body %}
73
+ {% extends "layout.html" %}
74
+
75
+ {% block body %}
258
76
 
259
77
  Welcome to Heroku!
260
78
 
@@ -268,7 +86,7 @@
268
86
 
269
87
  ```indexpy
270
88
 
271
- from flask import Flask , render_template
89
+ from flask import Flask , render_template , request
272
90
 
273
91
  from models.fin import nn
274
92
 
@@ -278,13 +96,19 @@
278
96
 
279
97
 
280
98
 
281
- @app.route('/', methods=['POST'])
99
+ @app.route('/')
282
100
 
283
101
  def index():
284
102
 
285
- name = request.form.getlist("name")
103
+     return render/template('index.html')
286
104
 
105
+
106
+
107
+ @app.route('/result', methods=['GET', 'POST'])
108
+
109
+ name = request.form["name"]
110
+
287
- num = request.form.getlist("num")
111
+ num = request.form["num"]
288
112
 
289
113
  ui = nn(name,num)
290
114
 
@@ -294,7 +118,7 @@
294
118
 
295
119
  if __name__ == '__main__':
296
120
 
297
- app.run(host='0.0.0.0', port=5000, debug=True)
121
+ app.run(debug=True)
298
122
 
299
123
  ```
300
124
 
@@ -316,19 +140,13 @@
316
140
 
317
141
  ```
318
142
 
319
- heroku_dir---Procfile
143
+ heroku_dir---index.py
320
-
321
- README.md
322
-
323
- requirements.txt
324
-
325
- index.py(自作)
326
144
 
327
145
  templates---index.html
328
146
 
329
147
  layout.html
330
148
 
331
- models---fin.py(自作)
149
+ models---fin.py
332
150
 
333
151
  ```
334
152
 
@@ -338,4 +156,4 @@
338
156
 
339
157
 
340
158
 
341
- Mac、python3.8.8、Herokuを使用しています
159
+ Mac、python3.8.8,ロリポップFTPを使用しています

2

追加

2021/12/18 08:08

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -244,16 +244,12 @@
244
244
 
245
245
  <h3>{{ui}}</h3>
246
246
 
247
+ {% block body %}{% endblock %}
248
+
247
249
  </body>
248
250
 
249
251
  </html>
250
252
 
251
- {% block body %}{% endblock %}
252
-
253
- </body>
254
-
255
- </html>
256
-
257
253
  ```
258
254
 
259
255
  ```indexhtml

1

追加

2021/11/14 12:01

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -342,4 +342,4 @@
342
342
 
343
343
 
344
344
 
345
- Mac、python3.8、Herokuを使用しています
345
+ Mac、python3.8.8、Herokuを使用しています