[TIL] flask app.route()

Captainjack·2022년 11월 9일
0

TIL

목록 보기
244/258
#!/usr/bin/python3
from flask import Flask, request, render_template, make_response, redirect, url_for
#플래스크 시작


app = Flask(__name__) # double underscores (__name__) 현재 활성 모듈을 나타냄


@app.route('/admin') 

맨 앞에 @을 붙이면 장식자(decorator)로 URL 연결에 활용된다.
장식자 사용 후 다음 행의 함수부터 장식자가 적용된다.

  • 함수 장식자는 함수 코드를 바꾸지 않아도, 장식자 안의 내용을 바꿈으로 동작을 설정가능하다.

@app.route('/admin')
def admin():
    # what is it? Does this page tell you session? 
    # It is weird... TODO: the developer should add a routine for checking privilege 
    return session_storage


if __name__ == '__main__':
    import os
    # create admin sessionid and save it to our storage
    # and also you cannot reveal admin's sesseionid by brute forcing!!! haha
    session_storage[os.urandom(32).hex()] = 'admin'
    print(session_storage)
    app.run(host='0.0.0.0', p
    ort=8000)
profile
til' CTF WIN

0개의 댓글