発生している問題・エラーメッセージ
pythonでbottleを使って簡単なWebアプリを作成しました。
それをHerokuを使って公開したのですが、ページの遷移が上手くいきません。
コマンドプロントとChromeを使った際は、最初にhttp://localhost:8080にアクセスし、その後ボタンを押すと、
http://localhost:8080/pushといった感じにページ遷移するようになっています。
これをHeroku上で動かすとhttp://localhost:8080にあたるhttps://hogehoge.herokuapp.com/は表示できたのですが、ボタンを押してhttp://localhost:8080/pushにあたるページ
https://hogehoge.herokuapp.com/pushに遷移すると、Internal Server Errorが発生してしまいます。
ファイル構造
root/
├ hoge.py
├ views/
│ └ index.html
│ └ push.html
###コード概要
//hoge.py
最初はここにルーティングされ、ここでは正常に動作しています。
@route("/")
def index():
return template("index")
index.html内でボタンを押した場合ここにルーティングします。
その際にhttps://hogehoge.herokuapp.com/pushでInternal Server Errorが発生してしまいます。
@route("/push", method=["POST"])
def push:
return redirect("/push")
@route("/push")
def push():
return template("push")
###Heroku logs
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 314: invalid start byte
10.171.115.37 - - [30/Jun/2018 02:32:29] "GET /post HTTP/1.1" 500 774
上記では省略しているのですが、def push():内でCSVからデータを読み込んでいるのですが、そこでエラーが発生しているみたいです。
with open('./data.csv', 'r') as f:
reader = csv.reader(f)
for row in reader:...
###原因
CSVファイルの中身がいけなかったみたいで、いったん作り直したらうまくいきました。
回答2件
あなたの回答
tips
プレビュー