LoginSignup
2
1

More than 5 years have passed since last update.

Python(Bottle,Intellij)で Debug ステップ実行

Last updated at Posted at 2015-03-28

ステップ実行するまで手間取ったのでメモ

  • 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!
2
1
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
2
1