From: Eric Fayolle Date: Thu, 27 Jan 2022 16:46:19 +0000 (+0100) Subject: Gestion des menus... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=860e238bcdf9a11e75f7822d11f001b14b325a4e;p=tools%2Feficas.git Gestion des menus... --- diff --git a/testFlask/mdm.py b/testFlask/mdm.py index 75c7a5d0..236ba863 100755 --- a/testFlask/mdm.py +++ b/testFlask/mdm.py @@ -9,12 +9,34 @@ code='Essai' from flask import Flask, request, render_template, url_for, jsonify, make_response, session, g, Response # from flask import Flask, request, render_template, url_for, json, jsonify import json +import os from pprint import pprint -from forms import BasicForm +#from forms import BasicForm from collections import OrderedDict from markupsafe import escape from flask_sse import sse +from flask_uploads import UploadSet, configure_uploads, IMAGES + +app = Flask(__name__) + +CATALOGS_EXT=("py",) +catalogs = UploadSet("catalogs",CATALOGS_EXT) +app.config["UPLOADED_CATALOGS_DEST"] = "data/catalogs" +app.config["SECRET_KEY"] = os.urandom(24) + + +configure_uploads(app, catalogs) + +@app.route("/upload", methods=['POST']) +def upload(): + if request.method == 'POST' and 'catalogFile' in request.files: + catalogs.save(request.files['catalogFile']) + # flash("Catalog saved successfully.") + # return render_template('upload.html') + # return render_template('upload.html') + return "upload returns", 200 + # For example, you may want to override how request parameters are handled to preserve their order: # from flask import Flask, Request @@ -30,8 +52,6 @@ def createConnecteur(app): monConnecteur=accasConnecteur(code, langue='ang',appWeb=app) return monConnecteur -app = Flask(__name__) - monConnecteur=createConnecteur(app) print (monConnecteur.getListeCommandes()) @@ -173,14 +193,6 @@ def index(): # myFancyTreeJS=json.dumps([myFancyTreeDico]) myFancyTreeJS=json.dumps([myFancyTreeDico],indent=4) #TODO : remove indent if not DEBUG - # myNewTreeDico=OrderedDict([('text', 'MonProc2'), ('nodes', OrderedDict([('text', 'MonProc22'), ('nodes', [{'text': 'param1 1.0'}, [OrderedDict([('text', 'Fact1'), ('nodes', [{'text': 'param3 43.0'}])]), OrderedDict([('text', 'Fact1'), ('nodes', [{'text': 'param3 44.0'}])])]])]))]) - # myNewTreeJS=json.dumps([myNewTreeDico]) - # print("---- myTreeDico : ") - # pprint.pprint(myTreeDico) - # print("---- myTreeJS : ", myTreeJS) - # print("---- tree4Fancy : ", tree4Fancy) - # print("---- myNewTreeDico : ", myNewTreeDico) - # print("---- myNewTreeJS : ", myNewTreeJS) print("---- myFancyTreeDico ----") pprint(myFancyTreeDico) print("---- myFancyTreeJS ----") @@ -244,11 +256,11 @@ def removeNode(): req = request.get_json() # Print the dictionary print("/removeNode ",req);print("/removeNode ",req['id']); - id =req['id']; + id = req['id']; ret,message = monConnecteur.suppNode(id); print ("/removeNode : ret : ",ret," message : ",message) - return make_response(json.dumps( {'ret':ret} )) + return make_response(json.dumps( {'ret':ret, 'message':message} )) else: # The request body wasn't JSON so return a 400 HTTP status code return "Request was not JSON", 400 @@ -266,7 +278,7 @@ def appendChild(): # id, value = req.values() # Dangereux correspondance implicite #rId,message,changeDone = monConnecteur.appendChild(id,name,pos); newId = monConnecteur.appendChild(id,name,pos); - print (__file__+"/appendChild : newId : ",newId) + print (__file__+"/appendChild : newId : ",newId); return make_response(json.dumps( {'id':newId} )) # return make_response(json.dumps( {'source':node, 'changeIsAccepted' : changeDone, 'message': message} )) @@ -276,8 +288,8 @@ def appendChild(): # The request body wasn't JSON so return a 400 HTTP status code return "Request was not JSON", 400 #return make_response(jsonify({"message": "Request body must be JSON"}), 400) - - + + @app.route("/forward/", methods=['POST']) def move_forward(): #Moving forward code diff --git a/testFlask/templates/base.html b/testFlask/templates/base.html index 4635a200..c866ab8e 100644 --- a/testFlask/templates/base.html +++ b/testFlask/templates/base.html @@ -8,7 +8,7 @@ - + @@ -42,7 +42,7 @@ - + @@ -51,22 +51,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - -