diff --git a/Sources/pyOpenRPA/Orchestrator/Server.py b/Sources/pyOpenRPA/Orchestrator/Server.py index 2283dc2c..5d0b84c3 100644 --- a/Sources/pyOpenRPA/Orchestrator/Server.py +++ b/Sources/pyOpenRPA/Orchestrator/Server.py @@ -30,6 +30,7 @@ from . import __Orchestrator__ import copy import mimetypes mimetypes.add_type("font/woff2",".woff2") +mimetypes.add_type("text/javascript",".js") gCacheDict = {} @@ -288,18 +289,22 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): # Write content as utf-8 data inResponseDict["Body"] = gCacheDict[inURLItem["ResponseFilePath"]] else: + if os.path.exists(inURLItem["ResponseFilePath"]) and os.path.isfile(inURLItem["ResponseFilePath"]): + lFileObject = open(CrossOS.PathStr(inURLItem["ResponseFilePath"]), "rb") + # Write content as utf-8 data + gCacheDict[inURLItem["ResponseFilePath"]] = lFileObject.read() + inResponseDict["Body"] = gCacheDict[inURLItem["ResponseFilePath"]] + # Закрыть файловый объект + lFileObject.close() + else: inResponseDict["Headers"]["Content-type"]= "application/x-empty"; inResponseDict["StatusCode"] = 204 # NOCONTENT + else: + if os.path.exists(inURLItem["ResponseFilePath"]) and os.path.isfile(inURLItem["ResponseFilePath"]): lFileObject = open(CrossOS.PathStr(inURLItem["ResponseFilePath"]), "rb") # Write content as utf-8 data - gCacheDict[inURLItem["ResponseFilePath"]] = lFileObject.read() - inResponseDict["Body"] = gCacheDict[inURLItem["ResponseFilePath"]] + inResponseDict["Body"] = lFileObject.read() # Закрыть файловый объект lFileObject.close() - else: - lFileObject = open(CrossOS.PathStr(inURLItem["ResponseFilePath"]), "rb") - # Write content as utf-8 data - inResponseDict["Body"] = lFileObject.read() - # Закрыть файловый объект - lFileObject.close() + else: inResponseDict["Headers"]["Content-type"]= "application/x-empty"; inResponseDict["StatusCode"] = 204 # NOCONTENT # detect MIME type if none if inResponseDict["Headers"]["Content-type"] is None: inResponseDict["Headers"]["Content-type"]= mimetypes.guess_type(inURLItem["ResponseFilePath"])[0] @@ -320,7 +325,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): if inURLItem["URL"][-1]!="/": inURLItem["URL"]+= "/" # Fix for settings lFilePathSecondPart = lRequestPath.replace(inURLItem["URL"],"") lFilePathSecondPart = lFilePathSecondPart.split("?")[0] - lFilePath = os.path.join(CrossOS.PathStr(inURLItem["ResponseFolderPath"]),lFilePathSecondPart) + lFilePath = CrossOS.PathStr(os.path.join(inURLItem["ResponseFolderPath"],lFilePathSecondPart)) #print(f"File full path {lFilePath}") #Check if file exist if os.path.exists(lFilePath) and os.path.isfile(lFilePath): @@ -345,6 +350,8 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): # detect MIME type if none if inResponseDict["Headers"]["Content-type"] is None: inResponseDict["Headers"]["Content-type"]= mimetypes.guess_type(lFilePath)[0] + else: + inResponseDict["Headers"]["Content-type"]= "application/x-empty"; inResponseDict["StatusCode"] = 204 # NOCONTENT # If No content-type if inResponseDict["Headers"]["Content-type"] is None: inResponseDict["Headers"]["Content-type"]= "application/octet-stream" diff --git a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py index f9951b95..4cb04674 100644 --- a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py +++ b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py @@ -458,15 +458,14 @@ def pyOpenRPA_Agent_A2O(inRequest, inGSettings): inGSettings["AgentDict"][lAgentDictItemKeyTurple]["ActivityList"] = lAgentDictActivityListNew from pyOpenRPA.Utils.Render import Render -gPackageResourcePathStr = os.path.join(*(CrossOS.PathSplitList(__file__)[:-2])) -gRender = Render(inTemplatePathStr=os.path.join(gPackageResourcePathStr, "Resources","Web","orpa","orc.xhtml")) +lFileStr = CrossOS.PathJoinList(CrossOS.PathSplitList(__file__)[:-2] + ["Resources","Web","orpa","orc.xhtml"]) +gRender = Render(inTemplatePathStr=lFileStr,inTemplateRefreshBool=True) def pyOpenRPA_Index(): # Пример использования global gRender - gRender.TemplatePathSet(inDataDict={"const":"value1"}) lStr = gRender.Generate() - __Orchestrator__.WebRequestResponseSend(inResponeStr=lStr,inContentTypeStr="html/text") + __Orchestrator__.WebRequestResponseSend(inResponeStr=lStr,inContentTypeStr="text/html") def SettingsUpdate(inGlobalConfiguration): import os @@ -486,8 +485,10 @@ def SettingsUpdate(inGlobalConfiguration): # "ResponseDefRequestGlobal": None #Function with str result #} #Orchestrator basic dependencies # Index page in server.py because of special settings - {"Method":"GET", "URL": gSettingsDict["ServerDict"]["URLIndexStr"],"MatchType": "EqualNoParam", "ResponseDef": pyOpenRPA_Index}, + {"Method":"GET", "URL": gSettingsDict["ServerDict"]["URLIndexStr"],"MatchType": "EqualNoParam", "ResponseDefRequestGlobal": pyOpenRPA_Index}, + {"Method":"GET", "URL": "/metadata.json", "MatchType": "EqualCase", "ResponseFilePath": os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\orpa\\metadata.json"), "ResponseContentType": "application/json"}, {"Method":"GET", "URL": "/Index.js", "MatchType": "EqualCase", "ResponseFilePath": os.path.join(lOrchestratorFolder, "Web\\Index.js"), "ResponseContentType": "text/javascript"}, + {"Method":"GET", "URL": "/orpa/Resources/", "MatchType": "BeginWith", "ResponseFolderPath": os.path.join(lOrchestratorFolder, "..\\Resources"),"UACBool":False, "UseCacheBool": True}, {"Method":"GET", "URL": "/3rdParty/Semantic-UI-CSS-master/semantic.min.css", "MatchType": "EqualCase", "ResponseFilePath": os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.css"), "ResponseContentType": "text/css", "UACBool":False, "UseCacheBool": True}, {"Method":"GET", "URL": "/3rdParty/Semantic-UI-CSS-master/semantic.min.js", "MatchType": "EqualCase", "ResponseFilePath": os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.js"), "ResponseContentType": "application/javascript", "UACBool":False, "UseCacheBool": True}, {"Method":"GET", "URL": "/3rdParty/jQuery/jquery-3.1.1.min.js", "MatchType": "EqualCase", "ResponseFilePath": os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\jQuery\\jquery-3.1.1.min.js"), "ResponseContentType": "application/javascript", "UACBool":False, "UseCacheBool": True}, diff --git a/Sources/pyOpenRPA/Resources/Web/orpa/footer.xhtml b/Sources/pyOpenRPA/Resources/Web/orpa/footer.xhtml index 530fc499..e470ebca 100644 --- a/Sources/pyOpenRPA/Resources/Web/orpa/footer.xhtml +++ b/Sources/pyOpenRPA/Resources/Web/orpa/footer.xhtml @@ -25,4 +25,13 @@ - \ No newline at end of file + + + + + + + + + + \ No newline at end of file diff --git a/Sources/pyOpenRPA/Resources/Web/orpa/header.xhtml b/Sources/pyOpenRPA/Resources/Web/orpa/header.xhtml index 38a6c08b..b6ed17db 100644 --- a/Sources/pyOpenRPA/Resources/Web/orpa/header.xhtml +++ b/Sources/pyOpenRPA/Resources/Web/orpa/header.xhtml @@ -1,3 +1,22 @@ + + + + + + + + + + + + + + + + + + +
@@ -26,4 +45,5 @@
- \ No newline at end of file + + diff --git a/Sources/pyOpenRPA/Resources/Web/orpa/styleset/metadata.json b/Sources/pyOpenRPA/Resources/Web/orpa/metadata.json similarity index 100% rename from Sources/pyOpenRPA/Resources/Web/orpa/styleset/metadata.json rename to Sources/pyOpenRPA/Resources/Web/orpa/metadata.json diff --git a/Sources/pyOpenRPA/Resources/Web/orpa/orc.xhtml b/Sources/pyOpenRPA/Resources/Web/orpa/orc.xhtml index 47cd115e..a27b873a 100644 --- a/Sources/pyOpenRPA/Resources/Web/orpa/orc.xhtml +++ b/Sources/pyOpenRPA/Resources/Web/orpa/orc.xhtml @@ -3,13 +3,13 @@ pyOpenRPA Orchestrator - + - - - + + +