ステップ実行するまで手間取ったのでメモ
- Intellij 12
- Python
- Botltle (Bottle でなくてもよいが今回は例として利用)
# bottle install
pip install bottle
- python プロジェクト作成
- project structure -> SDKs で ClassPath に pycharm-debug.egg を追加(自分の環境だと ~/Library/Application Support/IntelliJIdea12/python/pycharm-debug.egg にありました。)
- Debug の Edit Configuration から Python Remote Debug を追加し hostname と port を指定する
- index.py 作成
- views/index.tpl 作成
- intellij のデバッグ実行
- python index.py 実行
- http://localhost:8080/index にアクセス
index.py
# debug 設定に合わせた hostname と port を指定
import pydevd
pydevd.settrace('localhost', port=8080, stdoutToServer=True, stderrToServer=True)
from bottle import Bottle, run, template
apps = Bottle()
@apps.get('/index') # or @route('/login')
def login():
print 'Hello!' # プレークポイント置いてみる
return template("index")
run(app=apps, host='localhost', port=8080)
views/index.tpl
World!