python - can't run BottlePy -


i'm quite newbie python , bottlepy, question might seem dumb. can't run bottlepy-file, python-window disappears when should run bottlepy. know why python doesn't run code?

this bottlepy code (i use notepad++ edit codes)

from bottle import response, error, import json    @get('/hello') def hello_world(): '''responds http://localhost:8080/hello example json object ''' response_body = {'hello': 'world'}  # returns valid json in response, not yet set  # associated http response header.  should in  # own routes!  return json.dumps(response_body)  @get('/db-example') def db_example(db): '''responds names of products in amsterdam  add parameter 'db' function database cursor wtplugin. parameter db of type sqlite3.cursor. documentation @ https://docs.python.org/2/library/sqlite3.html#sqlite3.cursor  if want start clean sheet, delete file 'inventory.db'. automatically re-created , filled 1 example item.  access route @ http://localhost:8080/db-example ''' # execute sql statement select name of items located in a'dam db.execute("select name inventory location=?", ('amsterdam',))  # results in list of dictionaries names = db.fetchall() # use db.fetchone() results 1 one  # todo: set appropriate http headers , http response codes.  # return results json return json.dumps(names)   @error(404) def error_404_handler(e):  # content type must set manually in error handlers response.content_type = 'application/json'  return json.dumps({'error': {'message': e.status_line, 'status': e.status_code}})   if __name__ == "__main__": bottle import install, run wtplugin import wtdbplugin, wtcorsplugin  install(wtdbplugin()) install(wtcorsplugin()) run(host='localhost', port=8080, reloader=true, debug=true, autojson=false) 


Comments