PROJECTS

AssertionError: View function mapping is overwriting an existing endpoint function: decorated_function

nicesugi 2022. 5. 20. 11:18

 

๐Ÿ’š Github ์ฃผ์†Œ ๐Ÿ’š

https://github.com/nicesugi/turtlegram_frontend.git

https://github.com/nicesugi/turtlegram_backend.git

 

decorated_function, AssertionError

๋‘˜ ์ด์ƒ์˜ ํ•จ์ˆ˜๋ฅผ ๋ž˜ํ•‘ํ•˜๋ ค๋‹ค๊ฐ€ ๋ฐœ์ƒํ•œ ์˜ค๋ฅ˜๋‹ค.

 

ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์œผ๋กœ ๋ช‡ ๊ฐ€์ง€๋ฅผ ์ฐพ์•˜๋Š”๋ฐ, ๋‚ด๊ฐ€ ์‚ฌ์šฉํ•œ ๋ฐฉ๋ฒ•์€ wrap ์ด๋‹ค.

  • wrapper.__name__ = func.__name__
  • endpoint ๊ฐ’์„ ๋ณ€๊ฒฝ
  • ํ•จ์ˆ˜ ์ด๋ฆ„์„ ๋ฐ”๊พธ๊ธฐ
  • wrap ์œผ๋กœ ๋ฌถ๊ธฐ

 

20๋ฒˆ๊ณผ 21๋ฒˆ ์‚ฌ์ด์— @wrap์„ ์จ์ฃผ๋ฉด ํ•ด๊ฒฐ๋œ๋‹ค.

def authorize(f):
    @wraps(f)
    def decorated_function():
        if not 'Authorization' in request.headers:
            abort(401)
        token = request.headers['Authorization']
        try:
            user = jwt.decode(token, SECRET_KEY, algorithms=['HS256'])
        except:
            abort(401)
        return f(user)
    return decorated_function

 

์ฐธ๊ณ  : https://stackoverflow.com/questions/17256602/assertionerror-view-function-mapping-is-overwriting-an-existing-endpoint-functi

 

 

 

TurtleGram๐Ÿข | Python Js ๋ฐ”๋‹๋ผ์ฝ”๋“œ๋กœ ํ™ˆํŽ˜์ด์ง€ ๋งŒ๋“ค๊ธฐ

๐Ÿ’š Github ์ฃผ์†Œ ๐Ÿ’š

https://github.com/nicesugi/turtlegram_frontend.git

https://github.com/nicesugi/turtlegram_backend.git

๋ฐ˜์‘ํ˜•