Jump to content

marcovaldo

Members
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

1 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. marcovaldo

    Serving html page containing images

    Attila, thank you for advice! Any advice that this is very welcome, as security is always a very important aspect of IT...
  2. marcovaldo

    Serving html page containing images

    The slightly extended version of the handler now sends differnt images from [Application Bin folder]\img folder function TDominoServerResource.ServerImg([PathParam('*')] AllStrings: string): TStream; begin //DebLog.DebOut('ImageRequest:'+AllStrings+'*'); //AllStrings contains plain image filename Result := TFileStream.Create('img\'+AllStrings, fmOpenRead or fmShareDenyWrite); end; Why I wanted that MARS is also serving HTML pages for browser - Status Display - Setup functions (as my app normally is running as service) My old application used a telnet connection for that purpose but I bet that customer IT is nowadays unhappy having an open telnet connection on a productive server. The http connection can be protected by various auth methods.. Greetings
  3. marcovaldo

    Serving html page containing images

    Fixed: 1) Created a separate handler in MARS for images (similar to MARSContentType Demo): [GET, Path('/img/{*}'), Produces('image/jpg')] function ServerImg([PathParam('*')] AllStrings: string): TStream; and function TDominoServerResource.ServerImg([PathParam('*')] AllStrings: string): TStream; begin Result := TFileStream.Create('Sample.jpg', fmOpenRead or fmShareDenyWrite); end; Note: This sample serves only one fixed image to all requests. AllStrings needs to be processed still... 2) In HTML I had to take care not only on HTML SRC path but also on MARS/REST path <img src="/rest/default/myservername/img/Sample.jpg"> Waterfall mode of Chrome Browser is your friend! (as it showed what is requested by browser) Greetings to All, M.
  4. marcovaldo

    Serving html page containing images

    Many Thanks Attila, for your quick help! I am trying to play with the Bootstrap Server example (as I can edit html without compile) In Mars this page is served as follows function THelloWorldResource.SayHelloWorld: string; var LStreamReader: TStreamReader; begin LStreamReader := TStreamReader.Create('..\www\helloworld.html', TEncoding.UTF8); try Result := LStreamReader.ReadToEnd; finally LStreamReader.Free; end; end; What works: if the IMG is served from external server What doesn't work: if the IMG is referenced to local filesystem (location of binary) i thought that WEB root is application folder (maybee I am wrong?) Just try to find something in the web about this .... Greetings!
  5. Hi All, Beside using MARS as a REST server using JSON interface I also want to serve a few plain HTML pages used for status display with browsers. There shall be a table returned containing text and if possible images/icons beside that like Device1 online [an image] Device2 offline [ an other image] Is there any example how to do this? The images are shown as broken in browser. Does this need multiple endpoints to serve ? (One for the text and then one extra for every image, as the browser will do several HTTP connections to retrieve them) I am using Indy in a windows service (alternatively startable via /GUI as application) Kind Greetings, M.
  6. Solved. Need not the URL; generic meta refresh works for me..
  7. Hi, I am following down this path - but no success: - marsRequest stays nil - Also ading [HeaderParam] and [QueryParam] stay empty. What I am looking for is having the RequestURL to create an auto refresh status page which autorefreshs after a short time. Don't want to set URL as constant string... Any hints how to retrieve the Request URL simplest way (Just scrolling through Demo Code, but not seeing the trees instead of the wood...) Kind Greetings, Marcovaldo
  8. marcovaldo

    License Questions -

    Many thanks for your Answer - I want to do it the proper way, therefore was asking.
  9. marcovaldo

    License Questions -

    Hello All, Hi Kiriakos Vlahos, Many thanks, Kiriakos, for creating the P4D and Pyscripter! (I am only just scratchig on the surface, but I am allready aware that this is a great tool and opportunity) Question (maybee anybody here has a hint) if I include P4D Code into my commercial application, how do the different licenses propagate through the call stack: Delphi code (commercial project) D4P Interface Code (MIT license) Python code (PSFL similar to BSD license ) 3rd party Library (GPL or Commercial license ) Question: Isolates the D4P and Python layer the Delphi App from the GPL constraints or propagates this up so that I need either putting my App into GPL too or purchase a commercial license of the 3rd party lib? Kind greetings, marcovaldo
  10. Hi, Thx for your suggestions! In the meantime I am looking more into Using ICS for the downcomms. Something event driven might be easier for implementation with complex protocols handling many different kinds of protocols (needing timeouts, single byte answers etc.) Unfortunately there will be lost of (partially yet undefined) downstream protocols... And if I use Indy for the MARS (Uplink side) only I can later on decide to convert to apache module (NO - i think this will not work; Apache Module will run in a Apache Request/Answer Thread and will not have means to keep connections with the IoT sensor nodes continously ) Greetings, Marcovaldo
  11. Always finding first answers _after_ posting something... (I can confirm I have searched around before posting...) On ICS in Service and Application Example (Thx François Piette!)
  12. Hi All, I am working on a MARS Server (runnable as Application AND as Service). MARS REST interface is used to communicate with Enterprise IoT Servers (eg. Upstream comms) The same Server also shall communicate using various TCP protocols to IoT Sensors (eg Downstream comms) ? What TCP library would you recommend to use for this ? - Indy is used by (the stand alone server of MARS). Its a blocking/synchronous library (the downcomms will have to be moved into threads) ? Might using this interfere with the MARS internals? - ICS - I was very happy using this over the years in kind of Bread and butter VCL apps. But not sure if they depend much on Windows Message Loop / Events and might be difficult to handle in a Windows Service/ Multithreading enviroment (I will have to implement much to keep the engine under the hood running) (I think there is a Multiping Example by Angus Robertson at least, which might help me) ? Is it better to go for Indy or even for the Synapse lightweight library - because a linear comms task in a thread is simpler structure than all that message pump ens Event stuff ? Many thanks in advance for any suggestion guiding my half-noob in a swampy area! Seasonal Greetings & a good 2022! marcovaldo
  13. Final Remark: This confusion has been triggered by my specific setup (maybee no one else uses this...) => if you run a Win32 Service on Win64, then the current folder IS SysWOW64, no matter where the executable is located.
  14. Hi, I did not want to trigger a dispute about this :-0 Only wanted to share my findings - might they (possibly) be helpful to others... Yes, I tried absolute file locations before (like C:\certs\localhost.pem etc). did not work here (or only worked with application, not with service. Thank you for contributing to Indy & kind Greetings, m.
  15. They were ignored in application folder (if started as service) In my case they _have_been_ all the time in application folder. But only used by server compiled as application. When service has been started, it was terminated after a few seconds (Event entry: Service failed at start....) I first thought it has to do with my special setup (Delphi in VM, Project files outside in shared folder), but it also failed if i copied service application, OpenSSL dlls, certs to a local folder inside VM, like C:\Test. Could this be a special case of Win10 running in a VMWare Player VM then?
×