Python
-
Flask - Request Parameter Custom Function TypePython 2020. 7. 13. 21:13
def funmount(worktype): def funwork(val): if(worktype == 'kor'): if(val == None) return "무효합니다" return "유효합니다" else: return 'undef' return funwork @app.route('/test') def test(): rs = request.values.get('val1', '입력없음', type=funmount('kor')) return "val1의 결과: " + rs
-
Flask예제 - User Login 검사와 결과 처리Python 2020. 7. 13. 20:46
2020/07/13 - Flask - route 2020/07/13 - Flask - Response 2020/07/13 - Flask - Request Args, Form, Value 2020/07/13 - Flask - Request Parameter Custom Function Type 2020/07/13 - Flask - Cookie 2020/07/13 - Flask - Session import flask app = flask.Flask(__name__) app.debug = True app.secret_key = "aa" app.session_cookie_name = "sd_account" us = {'i1':'p1', 'i2':'p2'} @app.route("/login") def rt_lo..
-
Python - 변수 존재 유무 확인Python 2020. 7. 13. 16:49
방법1. Try Exception try : thevariable exception NameError : print('was not defined') else : print('it is defined') 방법2. 전체 목록에서 찾기 if('var1' in locals()): print('it is defined1') if('var2' in globals()): print('it is defined2') if('var2' in vars()): print('it is defined3') 방법3. 멤버변수 확인 if('attr_name' in dir(classobj)): print('it is defined') if(hasattr(classobj,'attr_name')): print('it is defined')