나는 파이썬 웹 개발을 막 시작했고 병을 나의 선택 틀로 선택했다.병 속에 서브 프로젝트 생성하기
모듈 구조의 프로젝트 구조를 갖기 위해 모듈을 둘러싼 모듈이있는 '핵심'응용 프로그램을 사용할 수 있습니다.이 모듈은 설치 중에 활성화되거나 비활성화 될 수 있으며, 가능하다면 ... 그걸 어떻게 설정할지 모르겠다.).
from bottle import Bottle, route, run
from bottle import error
from bottle import jinja2_view as view
from core import core
app = Bottle()
app.mount('/demo', core)
#@app.route('/')
@route('/hello/<name>')
@view('hello_template')
def greet(name='Stranger'):
return dict(name=name)
@error(404)
def error404(error):
return 'Nothing here, sorry'
run(app, host='localhost', port=5000)
내 '서브 프로젝트'(즉, 모듈)이있다 :
from bottle import Bottle, route, run
from bottle import error
from bottle import jinja2_view as view
app = Bottle()
@app.route('/demo')
@view('demographic')
def greet(name='None', yob='None'):
return dict(name=name, yob=yob)
@error(404)
def error404(error):
return 'Nothing here, sorry'
내 브라우저에서 http://localhost:5000/demo
로 이동, 그것은을 보여줍니다
내 '주'클래스는 다음과 같다 500 오류. 병 서버에서의 출력은 다음과 같습니다
localhost - - [24/Jun/2012 15:51:27] "GET/HTTP/1.1" 404 720
localhost - - [24/Jun/2012 15:51:27] "GET /favicon.ico HTTP/1.1" 404 742
localhost - - [24/Jun/2012 15:51:27] "GET /favicon.ico HTTP/1.1" 404 742
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/bottle-0.10.9-py2.7.egg/bottle.py", line 737, in _handle
return route.call(**args)
File "/usr/local/lib/python2.7/dist-packages/bottle-0.10.9-py2.7.egg/bottle.py", line 582, in mountpoint
rs.body = itertools.chain(rs.body, app(request.environ, start_response))
TypeError: 'module' object is not callable
폴더 구조는 다음과 같습니다
index.py
views (folder)
|-->hello_template.tpl
core (folder)
|-->core.py
|-->__init__.py
|-->views (folder)
|--|-->demographic.tpl
내가 어떻게 어떤 생각을 가지고 (잘못된) :
사람을 뭘하는지 모르겠어요 이/할 수 있습니까?
감사합니다.
잡았다 확인 아. 지금 작동 :) Thanks Rohan! – Jarrett