Python에서 Sinatra의 URL 라우팅을 다시 생성하는 방법이 있습니까? 그리고 이것이 바람직하지 않은 이유가 있습니까? 시나에서Sinatra 스타일 URL 라우팅을위한 Ruby 블록과 동일한 Python
: 나는 파이썬이하는 것을 수집
def get(path, opts={}, &block)
conditions = @conditions.dup
route('GET', path, opts, &block)
@conditions = conditions
route('HEAD', path, opts, &block)
end
:
@app.route("/")
def hello():
return "Hello World!"
시나 루비 블록을 통해이 간결을 달성 : 플라스크에서
get '/' do
'Hello world!'
end
(라우팅을위한 데코레이터 사용) Ruby 블록과 완전히 똑같은 것은 아니지만 기능을 재현 할 수있는 방법이 있습니다. 어떻게이 일을 할 수 있을까요?