From a8acb840812f0736d147249d90f906ac7ad1d6fd Mon Sep 17 00:00:00 2001 From: ignace Date: Fri, 23 Jan 2026 23:26:00 +0100 Subject: [PATCH] app updated to be served as a waitress backend service --- Config.py | 1 + README.md | 33 ++-- __pycache__/AccessControl.cpython-313.pyc | Bin 0 -> 2415 bytes __pycache__/Config.cpython-313.pyc | Bin 0 -> 395 bytes __pycache__/FlowerServices.cpython-313.pyc | Bin 0 -> 14459 bytes __pycache__/Log.cpython-313.pyc | Bin 0 -> 1195 bytes __pycache__/flower_vase.cpython-313.pyc | Bin 0 -> 10103 bytes __pycache__/flowers.cpython-313.pyc | Bin 0 -> 769 bytes flower_vase.py | 202 ++++++++++++++++++++ flowers.py | 204 +-------------------- templates/common.html | 14 +- templates/create.html | 2 +- templates/edit.html | 2 +- templates/index.html | 2 +- templates/rehush.html | 2 +- 15 files changed, 244 insertions(+), 218 deletions(-) create mode 100644 __pycache__/AccessControl.cpython-313.pyc create mode 100644 __pycache__/Config.cpython-313.pyc create mode 100644 __pycache__/FlowerServices.cpython-313.pyc create mode 100644 __pycache__/Log.cpython-313.pyc create mode 100644 __pycache__/flower_vase.cpython-313.pyc create mode 100644 __pycache__/flowers.cpython-313.pyc create mode 100644 flower_vase.py diff --git a/Config.py b/Config.py index 2db09b6..bdd30e6 100644 --- a/Config.py +++ b/Config.py @@ -6,3 +6,4 @@ MINFIELDLEN = 3 INFO = 1 DONOTSETFILTER = 'DoNotSetFilterinCookie' ACCESSFILE = '/tmp/wsgi_flower_accessfile' +URLPREFIX = '/flowers' diff --git a/README.md b/README.md index ab242b9..6551ac8 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,30 @@ -to install the dev env: +FLowers +------- + +The current code base is designed to run undert a waitress server as a backend to apache +The app should be called as http:// ... /flowers (so as a subfolder of the domain) + +to install the env: +python3 -m venv venv +source venv/bin/activate +pip install flask waitress fernet pymysql pytz -sudo pip3 install virtualenv -virtualenv p3env -source p3env/bin/activate -pip install uwsgi flask fernet pymysql +install apache and activate proxy: +a2enmod proxy +a2enmod proxy_http +and put the following in the site...conf file: + ProxyPass "/flowers" "http://127.0.0.1:5012/flowers" + ProxyPassReverse "/flowers" "http://127.0.0.1:5012/flowers" -to install kivi in the venv: -pip install Cython==0.23 -sudo apt-get install libgl1-mesa-dev -pip install kivy -pip install pygame -vi ~/.kivy/config.ini - change: multisamples = 0 # as root in mysql create database Flowers; grant create,select,update,insert,grant option on Flowers.* to flower@localhost identified by '608f0b988db4a96066af7dd8870de96c'; grant create user,reload on *.* to flower@localhost; -flush privileges; \ No newline at end of file +flush privileges; + +start waitress: +waitress-serve --threads=6 --host=127.0.0.1 --port=5012 --call flowers:create_app \ No newline at end of file diff --git a/__pycache__/AccessControl.cpython-313.pyc b/__pycache__/AccessControl.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b4c14bf6689bf3f53a72e1aa997a46d61c8988f5 GIT binary patch literal 2415 zcmbtV%}*Og6rcU@dW}E81``vLvfvO{L?9nR4d-AL-Y}0|v5N2o^ICr&}&(zIz&NK$QL!dlDA0iqBA~2X6 zMVMFE!w7p64!A&f$6m#Q#k?SUiEt^C(JgCRfQ1=%8@d~v;NZXe7-k=#G@WxO=_>nV zl6oGXvBr4cO808^dBSlSg+0q0hYK~CQDm}d8rh+w=xR-w^fz@^O9xzStZ{(TjZTcykd%Y|&xpbTBk&L)nQ}&@0=kA+A1t;;;3TcC%yN`rYDB00mVyy>B$RR56UsJXL_4P1iW}>4Rg-cEyCiPgtv`ZT@Da2tJyl$31=4PiI1vTylY}ppbdv}rBXg&q6TVQ?vc#`BC{hdHO$4n3 z9$DE#cuOzjNL$YML{}T1plbOd5lwx*?#q^P#G{)wUa;u5N|ea(=&jqHUO6bmDz1tO}dVH&oolGeIy#GUZLj@Gxp?xC%Cq8cAA$A_!& z6Xp1cr}0ydXR2dYei^&6@%{(pv1B=(+z?~6_UNLxT)OzpP}SdG_V;gv zqYrPd9j$~1)=zCE{9&~tUM?lixW}tf~hyur+hX*#p1OHeQzE4KFCw$ybzLtqY z-b|zPVHzQNElwT&3<|Up#$*9$)N+6TY3+bCF2yNq18Fn+k*09RgJ5T`MeB%4u?l|< z@U8)R@}BfwOxn;65>%;>^d6k0Xm*k6N~aF!#UG%ir-breS)9f+AYqNtHpEBU^oTb; z>!@c?%Ic<}XQf;bOLsrNEPF7m5==jg@P?Ty5&=xJnoW4{T#$L(MNK}Vq-C=h+8Ggm z&lPNZ1m-Qejsgq6LA|_rteLi+C7}jf8e>|#mI~}1s)ZwqLM_@=jrLcf{fm>e){d1M zOLtd|&DMchTjy%;1OHb7 z#B((Aj?-n=OuY z+nduS_u6a{TGv5>Hi=#b9e^V@)_5MAH}I9F`CpAJj~b1PpO#tN2LUnt0>aMU+@|1> zMGSyOn0`zhATg@ZJYuK>gaPP)m+ahZseuqoJ7(R#8?;w}fd{C&zX1x0D;m{(kVOBXBRTU){K!=cq|C74*lTY<>( z)cvVdz8V`W#|GE?*0oCD1hkCM(P}X9ESP8%e;{$`4EN+r%iDriW}LH3%RbuKOl?+& z&eo!;v&HOOf$9NO{di6*G%T&EnlrFv7YtK3i>g|`2zYW39-_=SR8&@lKpV~( zdFP@reMIXCp$M#RI8L>_AVhq#eu|6uEEs6rTXA4J9K$eMsN*>b|B70FL+vkli8=WK I0dp4r3nELxasU7T literal 0 HcmV?d00001 diff --git a/__pycache__/Config.cpython-313.pyc b/__pycache__/Config.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..26e30180b69624f2cb6a7a434ae1826ef12f05e7 GIT binary patch literal 395 zcmZ9HPfEi;6vmULF@I`W73{{9po7>wIDRml$rkyeqDRvbP;mQ+u z4NnnfCAjKB5PAV8(r$cq`iFR`puj?Jf-NCo`_WWF?KEFN0DXu(>%|$LN{`?uo}5p)EjxN X(Db}o9Jlg%VO@#cVe`eHMI_)2H_MdK(&ZPhBN+VjSue4=m_aA0=b{wEhC;g*) z&V3(}jT}fj-RRyJWfL39g3%T z-4W`rPS9}}rjO8vX@MqT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kmme(tH<9j8D*ylh literal 0 HcmV?d00001 diff --git a/__pycache__/Log.cpython-313.pyc b/__pycache__/Log.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cd1d1861111e1e6a9e0bf47c2ff3e1a49785b825 GIT binary patch literal 1195 zcmcgr&ubGw6n^_FNz;uFC`4?gp^q5`e#}%^oN@?dF>sIQH>>#X zgFy=lex3Jd_MkEdT#S&7DJ#V2j!M5ytgl~#FRe(+@jl~ZHsuw#6ay$k`3ykb&`G?H z`u}P`rK>Nk53=i+J=JHf{Bf2GF6=91A=%q{y%B6W?7DG*8_8T;sHO7!l2C&U#~1O% zrQ&>PaZYHP%nKc%RT}}v>E7I(m7>r#nCFN4vPklv>6jsUu8``S^fnAJm0!o@yyyCM z)ydZzHh;u%qGUXea?WgQ3DxuKfk==?NW-1{7MdsUV>rDtdzcw}^WbguQ)cSk_fMfnWFB-pPMw6NwwWs&29iNTuh*Nzb+-Nzzxy R9>Ul!H7#X-0-EmmzX34B<>3GT literal 0 HcmV?d00001 diff --git a/__pycache__/flower_vase.cpython-313.pyc b/__pycache__/flower_vase.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7e135f3072206a19626497e1b6252015d18227e2 GIT binary patch literal 10103 zcmcgSZA=_jlHEO@OwSje!#54s#5lIu*al*ocmp;N4-U3zurXl91Jl5SVTQb(F=p0r zh;+Kxcah9qyb8IC6n14@SSiwFbt|o-tdxy5ckx9h?eq@Ppbo3Gbe2x}by$vcr~J9A zdObZeCfJZu?w&O7v+BL7di7q_tLaA$hmC<$v>^vStYVmd!-k&B>B^&fEW`Ya5gC!~ zVZ1D1y&U1Z24WDfkLxkEa_r!%?+Rmcjww1c}V}0zo2;M))2bFCy&99`sA`d+Hy8=4?4)WXk~W`eiII?RB0^M?e=I_xs*Avi67fZ) znc0v(DygOkAZkiAz9IvvW5z!%`G_RXM#8cLi#cBE??2mlbzGW_;?(>ECCPWiPe*My z`7Dtpf>+}OO>)#94URXpO$0+y*g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8n(Dd{O(+pYrQGu zyn44V0J@gw*L0u)uIbDSPo&5AI6VXK|3=O__RIvCO4`tH+d!GArW>|_(#(-D8`&N_ zoH-As0n=8oZCy$tOW(&w;pNV5Wp;8_eu}i zs~H@0hT}WfCth@JM<+%YVZq&8fJoREbIOHzahmPr@~kKpe&L z+X8W`*vzcFr8h~9Fq#U2e_N7%%tXxS+Nl28OlFNX^eD9m3YudwikS~G*$f%=CWUm^ zWKJ6MfgG*`$0ZVj!CxTMe}JGC7%-&Hf?Gp>HMD&2qb8-aBk4G?(6wO{Opf)E%D1O( z@N2H}l&em0)!k`L)wd}1Eh$&4;%Z$lE_-L_Z-!P5-fdC@Z?d@OM%P9gV=q{E`I}~@ zq$=nAy`FxJHz>u8H%{uUy-M-^8zc8&rS|ZuyLr8=>izP+Enj&x@xrjOYb05AY08gLGe!&?F~?TVd$_y@h>jg`m&Ytwiz1hweMD@ z={GP0?`Qh0h-y9&2~PwkRf9Y)lNYi3G-Rq%i#?0lp_8?jAblgI!{&e%C6SPJ58%b1 z`Qi8^AZQl|I-|si8NTARmu5cJ3L#Sq;mechxD=Z_AnD)A$fO8ItUe#!cRrt*H_&(b zY+q;BsX;YQ3rqXPW>ph`(7QyxPN83AkjpqJzBDyY9q$LyfLSGG^dk;y+e{=73rWYx z0`$QnjgdW&Zx~pX{WH_5FsbE`A^LLhc?Dh zvN*Fmc(+lppIpe>urnP0X3ZNliTvG3w&5YivWFfS819)3tU>Hk8(l0+vc(TMj-6(4 zv}A);VT04d<;z!AV#|?*ngrYOkUPz?5`}Bs(CQl_oDNyGJh3vcJc^KqA9BU)2nB53 zpw*2Z>0nhWB_EkqoCwzXkaMzw6zus8THR>T!Ah1}miHjgvk$r5Yyr}?kJhN*{s(4i BnXLc- literal 0 HcmV?d00001 diff --git a/__pycache__/flowers.cpython-313.pyc b/__pycache__/flowers.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..818c1c36143754d5e3031f3734a3b191041869aa GIT binary patch literal 769 zcmYjO&ugmtUn#^gv2XTus%GXptWcpvDWKF_84YVxoa$U0_&NVRxAYaft^! z*`yZ_?ZtS|qc`vV6;%^)ViOZj-iZ7IzM)_{n|behZ{C~zzBltoB!pmn`0Sc*1%!U{ zV725Wm_GqI(;f{yLXBp=k;=~Kn&j|kNCy{wteu#j3TREkxtTznjt zC>O*6nr7)eqG?QS+E&{%*ab=q(;e_3bce*DrZu2k4NOPW9mnN56?Q$*v3n$88kXK9 zi8ddf3yu%(zu$H|7HU$W4~PbxbPYNs*zQd*6ZA8*aTqvAObXM>=A`ht^s2P~@)%#5 zV*hs>JI1kh`EU5zG`v13&7polwWphwrd7wmWGcIT8@{A@coC?HOlpzF&|tV@y90(D zn-2Ek0VXYoohl74pZ2-#l7*lJAIcwt$vuxVWFj3}9}$f}j)oWiyw|f^!!Ef`qY!fG zZVt>$6a?V}MNiO`zcLm!X6p#A?T^2Tn?EAagZgCm7Y=bjZ>sOZpSC8YFE~5%BOF`Y F{12-fv5o)$ literal 0 HcmV?d00001 diff --git a/flower_vase.py b/flower_vase.py new file mode 100644 index 0000000..40c3a7b --- /dev/null +++ b/flower_vase.py @@ -0,0 +1,202 @@ +from flask import Flask, Blueprint, send_from_directory +from Config import * +import sys +import datetime +import pytz +from FlowerServices import Flower,SuperFlower +from AccessControl import Access +import json +from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash, json, make_response +from werkzeug.exceptions import HTTPException + +# configuration +# DEBUG = False +# SECRET_KEY = 'development key' +flower_bp = Blueprint("flower_vase", __name__, url_prefix=URLPREFIX) + + +# app = Flask(__name__) +# app.config.from_object(__name__) + +@flower_bp.route('/static/') +def statix(filename): + return send_from_directory('static', filename) + +@flower_bp.route('/') +def index(): + print(request.remote_addr) + return render_template('index.html', name_suggestion="Hello", pwd_suggestion="Want to try your luck?") + +@flower_bp.route('/browser' , methods=['POST', 'GET']) +def application(): + now = datetime.datetime.now(pytz.timezone('Europe/Amsterdam')) + + if request.method == 'GET': + return render_template('index.html', name_suggestion="Faded out", pwd_suggestion="Want to retry your luck?") + + access_ctrl = Access() + if not access_ctrl.granted(request.remote_addr): + return render_template('index.html', name_suggestion="Sorry", pwd_suggestion="Access denied") + + action=request.form['action'] + filter='' + if 'filter' in session: + filter = session['filter'] + + if action == 'logout': + session['filter'] = request.form['filter'] + session['timeout'] = now - datetime.timedelta(minutes=999) + return render_template('index.html', name_suggestion="Bye", pwd_suggestion="Come back any time") + + + if action == 'login': + user=request.form['name'] + pwd=request.form['password'] + F = Flower(user, pwd) + if F.numberOfEntries()>=0: + session['dbuser'] = user + session['dbpwd'] = pwd + session['timeout'] = now + session['filter'] = filter + return render_template('list.html', flowers=F.all(), filter=filter) + #login failure + access_ctrl.deny(request.remote_addr) + print("Flowers - authorization failed for {}".format(user)) + return render_template('index.html', name_suggestion="Sorry", pwd_suggestion="Better next time") + + if 'timeout' in session and session['timeout']+datetime.timedelta(minutes=10)>now: + session['timeout'] = now + + if 'filter' in request.form.keys() and len(request.form['filter'])>1 and request.form['filter'] != DONOTSETFILTER: + session['filter']=request.form['filter'] + filter = request.form['filter'] + + F = Flower(session['dbuser'], session['dbpwd']) + if F.numberOfEntries()>=0: + + if action == 'list': + return render_template('list.html', flowers=F.all(), filter=filter) + + if action == 'show': + return render_template('show.html', flower=F.one(request.form['organization'], request.form['datetime'])) + + if action == 'edit': + return render_template('edit.html', flower=F.one(request.form['organization'], request.form['datetime'])) + + if action == 'new': + return render_template('edit.html', flower=F.empty()) + + if action == 'save': + flower = F.add(request.form['organization'],request.form['myname'],request.form['myid'],request.form['secret']) + session['filter']=request.form['organization'] + return render_template('show.html', flower=flower) + + if action == 'deactivate': + flower = F.deactivate(request.form['organization'],request.form['datetime']) + session['filter']='' + return render_template('show.html', flower=flower) + + if action == 'rehush': + return render_template('rehush.html', flower=F.empty()) + + + else: + return render_template('new.html', flower=F.empty()) + + + return render_template('index.html', name_suggestion="Sorry", pwd_suggestion="Better next time") + +@flower_bp.route('/create' , methods=['POST','GET']) +def create(): + access_ctrl = Access() + if not access_ctrl.granted(request.remote_addr): + return render_template('index.html', name_suggestion="Sorry", pwd_suggestion="Access denied") + + if 'name' not in request.form: + return render_template('create.html') + newuser = request.form['name'] + newhush = request.form['password'] + + # login db with generic user + f = SuperFlower(newuser, newhush) + if f.createNewTable(): + # login as new user + u = Flower(newuser, newhush) + # add one line + u.add('Demo organisation', 'Demo name', 'Demo login', 'Demo hush') + + # return to the login page + return render_template('index.html', name_suggestion="Now login", pwd_suggestion="for your very first time") + + return render_template('create.html', message="Sorry - System error - check log files") + + +@flower_bp.route('/update_pwd', methods=['POST','GET']) +def update_pwd(): + if 'name' not in request.form: + return render_template('rehush.html') + user = request.form['name'] + oldhush = request.form['old_password'] + newhush = request.form['new_password'] + + # login db with generic user + f = Flower(user, oldhush) + message = f.update_pwd(newhush) + + f = SuperFlower(user, oldhush) + f.flush_privs() + + return render_template('index.html', name_suggestion=message, pwd_suggestion="...") + + +# @app.route('/migrate', methods=['POST','GET']) +# def migrate(): +# user = 'ignace' +# hush = 'black' +# +# f = SuperFlower(user, hush) +# f.migrate(user) +# +# return render_template('index.html', name_suggestion='login again', pwd_suggestion="...") + +@flower_bp.route('/app' , methods=['POST']) +def web_service(): + # same thing as 'aplication, but returns go in json + result = json.dumps({'result': -1, 'message': 'Invalid entry'}) + + try: + access_ctrl = Access() + if not access_ctrl.granted(request.remote_addr): + result = json.dumps({'result': -1, 'message': 'Access denied'}) + + else: + #no session variables here - the client will take care of fileter and timeout + action = request.form['action'] + user = request.form['name'] + pwd = request.form['password'] + F = Flower(user, pwd) + if F.numberOfEntries() == -1: + #login failure + access_ctrl.deny(request.remote_addr) + result = json.dumps({'result': 0, 'message': 'Invalid username or password'}) + + elif action == 'login': + result = json.dumps({'result': 1, 'message': 'Access granted'}) + + elif action == 'list': + result = json.dumps({'result': 1, 'message': 'Ok', 'list': json.dumps(F.all())}) + + elif action == 'one': + result = json.dumps({'result': 1, 'message': 'Ok', 'flower': json.dumps( F.one(request.form['organization'], request.form['dateCreated']) )}) + + elif action == 'save': + result = json.dumps({'result': 1, 'message': 'Ok', 'flower': json.dumps(F.add(request.form['organization'],request.form['myname'],request.form['myid'],request.form['secret']) )}) + + elif action == 'deactivate': + result = json.dumps({'result': 1, 'message': 'Ok', 'flower': json.dumps(F.deactivate(request.form['organization'], request.form['dateCreated']))}) + + except: + pass + return result + + diff --git a/flowers.py b/flowers.py index fb286a7..27b7940 100644 --- a/flowers.py +++ b/flowers.py @@ -1,200 +1,16 @@ from flask import Flask -from Config import * -import sys -import datetime -import pytz -from FlowerServices import Flower,SuperFlower -from AccessControl import Access -import json -from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash, json, make_response -from werkzeug.exceptions import HTTPException - -# configuration -DEBUG = False -SECRET_KEY = 'development key' +from flower_vase import flower_bp -app = Flask(__name__) -app.config.from_object(__name__) - -@app.route('/') -def index(): - print(request.remote_addr) - return render_template('index.html', name_suggestion="Hello", pwd_suggestion="Want to try your luck?") - -@app.route('/browser' , methods=['POST', 'GET']) -def application(): - now = datetime.datetime.now(pytz.timezone('Europe/Amsterdam')) - - if request.method == 'GET': - return render_template('index.html', name_suggestion="Faded out", pwd_suggestion="Want to retry your luck?") - - access_ctrl = Access() - if not access_ctrl.granted(request.remote_addr): - return render_template('index.html', name_suggestion="Sorry", pwd_suggestion="Access denied") - - action=request.form['action'] - filter='' - if 'filter' in session: - filter = session['filter'] - - if action == 'logout': - session['filter'] = request.form['filter'] - session['timeout'] = now - datetime.timedelta(minutes=999) - return render_template('index.html', name_suggestion="Bye", pwd_suggestion="Come back any time") - - - if action == 'login': - user=request.form['name'] - pwd=request.form['password'] - F = Flower(user, pwd) - if F.numberOfEntries()>=0: - session['dbuser'] = user - session['dbpwd'] = pwd - session['timeout'] = now - session['filter'] = filter - return render_template('list.html', flowers=F.all(), filter=filter) - #login failure - access_ctrl.deny(request.remote_addr) - print("Flowers - authorization failed for {}".format(user)) - return render_template('index.html', name_suggestion="Sorry", pwd_suggestion="Better next time") - - if 'timeout' in session and session['timeout']+datetime.timedelta(minutes=10)>now: - session['timeout'] = now - - if 'filter' in request.form.keys() and len(request.form['filter'])>1 and request.form['filter'] != DONOTSETFILTER: - session['filter']=request.form['filter'] - filter = request.form['filter'] - - F = Flower(session['dbuser'], session['dbpwd']) - if F.numberOfEntries()>=0: - - if action == 'list': - return render_template('list.html', flowers=F.all(), filter=filter) - - if action == 'show': - return render_template('show.html', flower=F.one(request.form['organization'], request.form['datetime'])) - - if action == 'edit': - return render_template('edit.html', flower=F.one(request.form['organization'], request.form['datetime'])) - - if action == 'new': - return render_template('edit.html', flower=F.empty()) - - if action == 'save': - flower = F.add(request.form['organization'],request.form['myname'],request.form['myid'],request.form['secret']) - session['filter']=request.form['organization'] - return render_template('show.html', flower=flower) - - if action == 'deactivate': - flower = F.deactivate(request.form['organization'],request.form['datetime']) - session['filter']='' - return render_template('show.html', flower=flower) - - if action == 'rehush': - return render_template('rehush.html', flower=F.empty()) - - - else: - return render_template('new.html', flower=F.empty()) - - - return render_template('index.html', name_suggestion="Sorry", pwd_suggestion="Better next time") - -@app.route('/create' , methods=['POST','GET']) -def create(): - access_ctrl = Access() - if not access_ctrl.granted(request.remote_addr): - return render_template('index.html', name_suggestion="Sorry", pwd_suggestion="Access denied") - - if 'name' not in request.form: - return render_template('create.html') - newuser = request.form['name'] - newhush = request.form['password'] - - # login db with generic user - f = SuperFlower(newuser, newhush) - if f.createNewTable(): - # login as new user - u = Flower(newuser, newhush) - # add one line - u.add('Demo organisation', 'Demo name', 'Demo login', 'Demo hush') - - # return to the login page - return render_template('index.html', name_suggestion="Now login", pwd_suggestion="for your very first time") - - return render_template('create.html', message="Sorry - System error - check log files") - - -@app.route('/update_pwd', methods=['POST','GET']) -def update_pwd(): - if 'name' not in request.form: - return render_template('rehush.html') - user = request.form['name'] - oldhush = request.form['old_password'] - newhush = request.form['new_password'] - - # login db with generic user - f = Flower(user, oldhush) - message = f.update_pwd(newhush) - - f = SuperFlower(user, oldhush) - f.flush_privs() - - return render_template('index.html', name_suggestion=message, pwd_suggestion="...") - - -# @app.route('/migrate', methods=['POST','GET']) -# def migrate(): -# user = 'ignace' -# hush = 'black' -# -# f = SuperFlower(user, hush) -# f.migrate(user) -# -# return render_template('index.html', name_suggestion='login again', pwd_suggestion="...") - -@app.route('/app' , methods=['POST']) -def web_service(): - # same thing as 'aplication, but returns go in json - result = json.dumps({'result': -1, 'message': 'Invalid entry'}) - - try: - access_ctrl = Access() - if not access_ctrl.granted(request.remote_addr): - result = json.dumps({'result': -1, 'message': 'Access denied'}) - - else: - #no session variables here - the client will take care of fileter and timeout - action = request.form['action'] - user = request.form['name'] - pwd = request.form['password'] - F = Flower(user, pwd) - if F.numberOfEntries() == -1: - #login failure - access_ctrl.deny(request.remote_addr) - result = json.dumps({'result': 0, 'message': 'Invalid username or password'}) - - elif action == 'login': - result = json.dumps({'result': 1, 'message': 'Access granted'}) - - elif action == 'list': - result = json.dumps({'result': 1, 'message': 'Ok', 'list': json.dumps(F.all())}) - - elif action == 'one': - result = json.dumps({'result': 1, 'message': 'Ok', 'flower': json.dumps( F.one(request.form['organization'], request.form['dateCreated']) )}) - - elif action == 'save': - result = json.dumps({'result': 1, 'message': 'Ok', 'flower': json.dumps(F.add(request.form['organization'],request.form['myname'],request.form['myid'],request.form['secret']) )}) - - elif action == 'deactivate': - result = json.dumps({'result': 1, 'message': 'Ok', 'flower': json.dumps(F.deactivate(request.form['organization'], request.form['dateCreated']))}) - - except: - pass - return result +def create_app(): + app = Flask(__name__) + app.config["SECRET_KEY"] = 'adhf adsh 8347y92347rupqo;wjf cowuyergc9b24387ryx1 -923pqr pqwejf qy7i34' + app.register_blueprint(flower_bp) + return app if __name__ == '__main__': - app.secret_key = 'adhf adsh 8347y92347rupqo;wjf cowuyergc9b24387ryx1 -923pqr pqwejf qy7i34' - app.run(host='0.0.0.0', port=8080) + my_app = create_app() + # if needed - initialize data + my_app.run(debug=True, host='127.0.0.1', port=5012) + diff --git a/templates/common.html b/templates/common.html index 15dd417..1c7faef 100644 --- a/templates/common.html +++ b/templates/common.html @@ -9,12 +9,12 @@ {% block title %}Flowers{% endblock %} - - - - - - + + + + + + @@ -42,7 +42,7 @@ {% block content %} {% endblock %} -
+ diff --git a/templates/create.html b/templates/create.html index c80f180..8909a7d 100644 --- a/templates/create.html +++ b/templates/create.html @@ -12,7 +12,7 @@ {% block content %}
- +
diff --git a/templates/edit.html b/templates/edit.html index 73ff705..5db0c19 100644 --- a/templates/edit.html +++ b/templates/edit.html @@ -10,7 +10,7 @@ {% block content %}
- +
diff --git a/templates/index.html b/templates/index.html index 570a9f6..6da3a49 100644 --- a/templates/index.html +++ b/templates/index.html @@ -12,7 +12,7 @@ {% block content %}
- +
diff --git a/templates/rehush.html b/templates/rehush.html index 1a19d2c..aff6838 100644 --- a/templates/rehush.html +++ b/templates/rehush.html @@ -12,7 +12,7 @@ {% block content %}
- +