6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

さくらインターネットでPython bottleが動いたお話

Last updated at Posted at 2016-07-04

ちょうど思い出せば去年くらいに、さくらのレンタルサーバーでPythonはCGIで動いたけどbottleが何をどうやっても動かなかったお話をしたような気がします。結論から言うと、動きました。

どう問題を発見したか

さくらレンタルサーバーにbottleプロジェクト一式をアップロードします。コントローラー部分は.cgiに変更してパーミッションは755としておきます。bottle.pyはそのまま配置。

そのままアクセスすると

Status: 500 Internal Server Error Content-Type: text/plain Content-Length: 59 A server error occurred. Please contact the administrator.

と言われます。ここが一番躓いていた原因。ログを辿ってみると、

・File "/usr/local/lib/python2.7/wsgiref/handlers.py", line 86, in run
・File "/usr/local/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response
・File "/usr/local/lib/python2.7/wsgiref/handlers.py", line 217, in write

と言った感じで明らかに動いてます。エラーの問題はどこなんだ・・・。と探していると見つかりました。

”UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 358: ordinal not in range(128)”

なんとまぁユニコードエラーです。ローカル環境でもHeroku環境でも出なかった箇所のユニコードエラー。

どこに問題があったか

index.tpl の中にある日本語をサクサク消してみたところ無事動く事が判明。何なんだこのオチは・・・。

よくあるルーティング問題は.htaccessですんなり解決できたものの、このユニコードエラーはいかんともしがたい。これなんかいい解決方法が他にあるようなきがするので、ちょっと色々試します。

{{default_tag}} とかで読み込んだ日本語もエラー。イラつきます。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?