You are not logged in.
Pages: 1
I have my first SOA application working with authentication, and database services working correctly on localhost.
aModel := TSQLModel.Create([TSQLAuthGroup, TSQLAuthUser, TPeople, Tcust], ROOT_NAME);
try
AServer := TSQLRestServerDB.Create(aModel, ChangeFileExt(ExeVersion.ProgramFileName, '.db3'), True, '');
aHTTPServer := TSQLHttpServer.Create(PORT_NAME, [AServer], '+', useHttpApiRegisteringURI);
TSQLRestServerDB(AServer).CreateMissingTables;
This URL ///C:/PEWeb/PeMor/Server/files/peweb.html runs my login page correctly
This URL http://192.168.12.131/files/peweb.html
produces this result with the fiddler running
[Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.
What would the correct URL be to access the login page which is generated by peweb.html
Im trying to run the server on an intranet
Hope this makes sense, Can anyone help - thanks
Offline
Hi All
I guess this is where I really start to learn.
After Reading up about ReturnFileFromFolder and method based services. ive understood from your reply that I need to add a method to my TSQLRestServerDB
type
TMyServer = class(TSQLRestServerDB)
published
procedure Html(Ctxt: TSQLRestServerURIContext);
end;
procedure TMyServer.Html(Ctxt: TSQLRestServerURIContext);
begin
Ctxt.ReturnFileFromFolder('C:\PEWeb');
end;
in the code in the previous post
ive changed the line to
AServer := TMyServer.Create(aModel, ChangeFileExt(ExeVersion.ProgramFileName, '.db3'), True, '');
Not sure how to implement or even if im on the right track
Ive tried various implementations to no avail crashing the server spectacular, Am I on the right track.
Offline
Could you please define what 'crashing the server' means?
Sounds fine to me, as far as I can guess from the code you did show...
It follows https://synopse.info/files/html/Synopse … ml#TITL_95
Offline
Hi AB
A bit of over dramatization Im sure its my code that crashed it.
This was the log
20171109 19555609 DB pe.TMyServer(020AD560) CreateMissingTables on {"TSQLDatabase(0218ABC8)":{"FileName":"C:\\PEWeb\\PeMor\\Server\\pe.db3","IsMemory":false,"UseCache":true,"TransactionActive":false,"BusyTimeout":0,"CacheSize":10000,"PageSize":4096,"PageCount":11,"FileSize":45056,"WALMode":false,"Synchronous":"smFull","LockingMode":"lmNormal","MemoryMappedMB":0,"user_version":0,"OpenV2Flags":6,"BackupBackgroundInProcess":false,"BackupBackgroundLastTime":"","BackupBackgroundLastFileName":"","SQLite3Library":{"TSQLite3LibraryStatic(02060030)":{"Version":"3.19.2 with internal MM"}}}}
20171109 19555609 DB pe.TMyServer(020AD560) "GetTables":["AuthGroup","AuthUser","cust","People"]
20171109 19555609 trace pe.TMyServer(020AD560) BeginCurrentThread(THttpApiServer) root=root ThreadID=00001348 ThreadCount=32
20171109 19561314 EXCOS EAccessViolation (C0000005) at 005F8AC7 stack trace API 0056165B 00561684 0040B7B6 77096D4B 77096BD7 009B3692 009C59E4 769FEF8C 770B367A 770B364D
This was because I really do not know how to implement the method in my code TMyServer.Html(Ctxt: TSQLRestServerURIContext);
I used
AServer.html(aCtxt);
after
TSQLRestServerDB(AServer).CreateMissingTables;
Sorry for so much code in post
Offline
Thanks AB
Now I understand
Offline
Hi AB
I have implemented on the client side
type
TMyClient = class(TSQLHttpClient)
procedure DoMyObject(ahtml: TObject);
end;
procedure TMyClient.DoMyObject(ahtml: TObject);
var err: integer;
begin
Not sure what goes here
end;
Sorry to bother but I cant find doc or example of how to return the static HTML file in the client
Offline
Try something like this below, this is untested code.
// Server part
type
TMyServer = class(TSQLRestServerDB)
published
procedure Html(Ctxt: TSQLRestServerURIContext);
end;
procedure TMyServer.Html(Ctxt: TSQLRestServerURIContext);
var
FN: TFileName;
begin
FN := Ctxt.ResourceFileName;
if FN = '' then
FN := index.html;
Ctxt.ReturnFile('C:\PathToDirWithStaticFiles\' + FN, True);
end;
Then start your browser and type
http://localhost:80/html/index.html
You can also take a look at Project04ServerStatic.dpr from Samples dir.
And take a look at Boilerplate Delphi implementation that allows you to store static contents inside your exe file (as resources),
https://synopse.info/forum/viewtopic.ph … 285#p24285
Offline
Hi Igor
Thank you very much for the advice, I tried but with no success
I implemented the server code from sample 4 in my server. the server runs and the logs say all is good. but i can still only access my HTML file by double clicking it. All works correctly then I am able to log in with mormot security and all my soa services function.
This URL is ///C:/PEWeb/PeMor/Server/files/peweb.html
From my train of thought. The class and procedure TMyServer.Html(Ctxt: TSQLRestServerURIContext); Are declared in the server
Surely the client must call this procedure on the server. It this code that I don't know how to implement.???
My HTML file is generated in a Web Elevate app and my interface to mormot functions on all levels accept when trying to set the URL
http://192.168.12.131/files/peweb.html
Im assuming that the root folder is where my server executable is run from.
Apology's for my lack of understanding. I loaded Delphi Berlin starter about a year ago and am really enjoying pascal program and appreciate your patience.
Offline
Pages: 1