Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
BrookHTTPServer www folder
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Database standards OR Am ...
by
egsuh
[
Today
at 08:56:31 am]
FpDebug unexpected Assemb...
by
Marc
[
Today
at 08:46:38 am]
Who is Indy mattias?
by
jollytall
[
Today
at 08:26:24 am]
How to: create DLL file f...
by
KodeZwerg
[
Today
at 08:17:30 am]
Step-into the field sette...
by
ginoo
[
Today
at 08:11:29 am]
Offical launch of the 1 B...
by
Handoko
[
Today
at 07:59:07 am]
Big Numbers Math
by
iLya2IK
[
Today
at 07:13:20 am]
Lazarus for Windows on aa...
by
dbannon
[
Today
at 07:02:55 am]
BUG REPORT: Unable to gen...
by
dbannon
[
Today
at 06:29:49 am]
what to do if my target M...
by
Laksen
[
Today
at 12:49:12 am]
For-in loop over constant...
by
ASerge
[
Today
at 12:36:09 am]
Converting a string/index...
by
TRon
[April 18, 2024, 11:56:37 pm]
exclude ALL packages from...
by
PascalDragon
[April 18, 2024, 11:33:29 pm]
Demoscene The Champs Crac...
by
KodeZwerg
[April 18, 2024, 11:29:50 pm]
Poll: Watches and Display...
by
440bx
[April 18, 2024, 10:55:14 pm]
Have anyone develop UEFI ...
by
PascalDragon
[April 18, 2024, 10:14:15 pm]
The weird Rewrite bug
by
PascalDragon
[April 18, 2024, 09:58:53 pm]
Assign (textfile) not com...
by
PascalDragon
[April 18, 2024, 09:51:50 pm]
Question for people who h...
by
PascalDragon
[April 18, 2024, 09:44:32 pm]
Linux Workspaces -- StayO...
by
AmatCoder
[April 18, 2024, 08:34:20 pm]
I just released a commerc...
by
Seenkao
[April 18, 2024, 07:57:21 pm]
Access violation when re-...
by
TRon
[April 18, 2024, 07:37:31 pm]
[SOLVED] assembler name i...
by
TRon
[April 18, 2024, 07:26:33 pm]
A fairly simple sound sol...
by
KodeZwerg
[April 18, 2024, 07:01:52 pm]
[Fun Fact] PNG and Micros...
by
Ten_Mile_Hike
[April 18, 2024, 06:24:19 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: BrookHTTPServer www folder (Read 1500 times)
promisetom
New Member
Posts: 11
BrookHTTPServer www folder
«
on:
April 23, 2021, 02:21:22 am »
Hi All,
I am building a Brook HttpServer with SSE and I would like to have the css and js files served from a local folder.
Where in the Brook framework do I add this location.
Thanks in advance
Tom
Logged
egsuh
Hero Member
Posts: 1291
Re: BrookHTTPServer www folder
«
Reply #1 on:
April 23, 2021, 07:33:28 am »
Aren't css and js files defined within HTML file?
Logged
PierceNg
Sr. Member
Posts: 373
Re: BrookHTTPServer www folder
«
Reply #2 on:
April 23, 2021, 09:10:54 am »
Quote from: egsuh on April 23, 2021, 07:33:28 am
Aren't css and js files defined within HTML file?
Yes. They usually exist as separate files on the server. From a web server (application) perspective, they also have to be served as static content when the web browser follows the references in the HTML file and requests for these CSS and JS files.
Logged
Pascal blog posts, open source:
-
https://samadhiweb.com/tags/Pascal.html
-
https://github.com/PierceNg/fpwebview
-
https://github.com/PierceNg/wasm-demo
promisetom
New Member
Posts: 11
Re: BrookHTTPServer www folder
«
Reply #3 on:
April 24, 2021, 01:15:08 am »
In a Delphi app using Overbyte ics they have a DocDir which relates to the www folder in Apache etc.
This is what I need.
Tom
Logged
promisetom
New Member
Posts: 11
Re: BrookHTTPServer www folder
«
Reply #4 on:
April 26, 2021, 03:33:27 am »
Found this idea and it works well.
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
OnRequest
(
Sender
:
TObject
;
var
ARequest
:
TFPHTTPConnectionRequest
;
var
AResponse
:
TFPHTTPConnectionResponse
)
;
var
AFilename
:
String
;
begin
AFilename
:
=
ARequest
.
URI
;
{Get rid of the starting bars so we won't serve from '/'
Theres should be only one, but just in case ...}
while
AFilename
.
StartsWith
(
'/'
)
or
AFilename
.
StartsWith
(
'.'
)
do
Delete
(
AFilename
,
1
,
1
)
;
{Alternatively, one could just do:
AFilename := GeCurrentDir + AFilename;
or whatever the web-root directory is,
but that's not very secure}
{ If we find the file, serve it; if not, fawn about it}
if
FileExists
(
AFilename
)
then
begin
AResponse
.
Code
:
=
200
;
AResponse
.
Content
:
=
ReadFileToString
(
AFilename
)
;
end
else
begin
AResponse
.
Code
:
=
404
;
AResponse
.
Content
:
=
'Sorry, don'
't have any "'
+
AFilename
+
'"'
;
end
;
end
;
from here.
https://forum.lazarus.freepascal.org/index.php/topic,36178.15.html
I will post a webserver demo soon.
Tom
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
BrookHTTPServer www folder
TinyPortal
© 2005-2018