From df74ddee532780a4e1213064a4f0521e19215725 Mon Sep 17 00:00:00 2001 From: thanhthtran Date: Thu, 19 Sep 2024 17:48:48 -0700 Subject: [PATCH] Add flask --- FlaskExercise/.DS_Store | Bin 0 -> 6148 bytes FlaskExercise/__init__.py | 12 +++++++ .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 467 bytes .../__pycache__/__init__.cpython-39.pyc | Bin 0 -> 465 bytes .../__pycache__/views.cpython-310.pyc | Bin 0 -> 783 bytes FlaskExercise/static/.DS_Store | Bin 0 -> 6148 bytes FlaskExercise/static/main.css | 26 +++++++++++++++ FlaskExercise/templates/.DS_Store | Bin 0 -> 6148 bytes FlaskExercise/templates/index.html | 30 ++++++++++++++++++ FlaskExercise/views.py | 22 +++++++++++++ 10 files changed, 90 insertions(+) create mode 100644 FlaskExercise/.DS_Store create mode 100644 FlaskExercise/__init__.py create mode 100644 FlaskExercise/__pycache__/__init__.cpython-310.pyc create mode 100644 FlaskExercise/__pycache__/__init__.cpython-39.pyc create mode 100644 FlaskExercise/__pycache__/views.cpython-310.pyc create mode 100644 FlaskExercise/static/.DS_Store create mode 100644 FlaskExercise/static/main.css create mode 100644 FlaskExercise/templates/.DS_Store create mode 100644 FlaskExercise/templates/index.html create mode 100644 FlaskExercise/views.py diff --git a/FlaskExercise/.DS_Store b/FlaskExercise/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3e329c3e79a52c3c4a9efbe1f31ada412a09cafc GIT binary patch literal 6148 zcmeHK!AiqG5S`Upw-vDmL63X!)Nvq4A9vvLkbzVsKxX9>sdwmReNWp*NfN!=u6G;;&H>_!0Oxo>6U0AK1>9oQ(wwk*Km)Eyd zC;W*kq|3;kVn81kzVfG5Z5C@7Fbww1DY!_i>l+( zNXQg&I#81;gS<4f|5j<>8jPy+1Pr|#swy5d?o?r4Ml+SCrP7i09+^_;5;WaWqnxLf h!g;TFt;t!Y;!47~{VHS*EfCbf#PRWgOK@ki{s7q}gY^Ia literal 0 HcmV?d00001 diff --git a/FlaskExercise/__pycache__/__init__.cpython-39.pyc b/FlaskExercise/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7945fae58663b03300ac6ffa4a4249983f934b5c GIT binary patch literal 465 zcmY*WyH3L}6t$Bk4WU6ud_{*ef{6hkD#}Z$I?w^hLReOFo2EE%WG5}K@&|lDJMv3e znGk=##7!ln_F6u^k0YOBSpA%QLe-+td37Z zAydesftpkq8LTBADPg zD|pNcE4B(dwhJeAxZzgr7GCUe2HwUO_6-+~aKExIJPw5Sj)nd&+Rs9#ac6m=7R>=d zDFCM$idCLyXaWS0A*8zT5k6L+bjTY!S*`APl$yQ&9!`!!HYQU@qS*!CSc2d1&+MAv z$u&i@wD3sV7tY2tv2a!nh&n`{w$u}DOCJ;Uh=wioh2PRH(SYblO9Rm{RCk2od*3X| zrZ&`?DGNmdQHU4FSWmeAX!}nWfAk(x$N^#V>>m;Y5HTE1ddM%-^bNWF* z6YLlvceQp zG=3{9aRzJ1<%;r*3Rz}a;*ic9DxIJPjNVYAm*-c2X{I1rXK<-Tt51z%PBJm8CnP<~ zu>-!(AFRi%_VxbY5iOX6o$Z}jBHhpX&`tlhdH4T2Wt+K+vZ4UY?l!v}c|@!UUKCPP SIlMGiNtyZ_vmOuZef}3JcFLRp literal 0 HcmV?d00001 diff --git a/FlaskExercise/static/.DS_Store b/FlaskExercise/static/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2b7e048a42434daf374d9ea4638c5d9e3c16dd03 GIT binary patch literal 6148 zcmeHKyG{c^3>-s>lW0;>Zb^kiO|yzZLCp_9LW2}Y5v9M1@8Zvr@k5B{ph7fgEZMW` z_1xyBIL82Nv46e+<^Tq|Bi=ns&ClH@c2*f9()o;Qtg*xHezRRqs=rS-cfc#2@PfCm z{MBZ=;+g-jTl&=@j4PQGkOERb3P=Gd@EZlZ_tJ)oL`5ke1*E{I0{(qybjMyeCdQ|O zAw~e=jOj40W0oK`PY`?In8*yxl1faf)ret9XTDWkFB}t-4vU-loVwX+Lb14=`4;7{ zo~S4Vq`;{H=eeDG|G%UEF#n&Dw37l-;9n_Vv*p8b!B?u@I(a$owT=Er_nHs78`nW$ mh;~ejcFc{pH1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 + + + + Monitoring & Logging + + + + + +
+
Logging Center
+
+ {% if log %} +

{{ log }}

+ {% endif %} +
+ + + + +
+
+ +
+ + \ No newline at end of file diff --git a/FlaskExercise/views.py b/FlaskExercise/views.py new file mode 100644 index 0000000..90070a9 --- /dev/null +++ b/FlaskExercise/views.py @@ -0,0 +1,22 @@ +from flask import flash, render_template, redirect, request +from FlaskExercise import app + + +@app.route('/') +def home(): + log = request.values.get('log_button') + # TODO: Appropriately log the different button presses + # with the appropriate log level. + if log: + if log == 'info': + app.logger.info('No issue.') + elif log == 'warning': + app.logger.warning('Warning occurred.') + elif log == 'error': + app.logger.error('Error occurred.') + elif log == 'critical': + app.logger.critical('Critical error occurred.') # noqa: E501 + return render_template( + 'index.html', + log=log + )