logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Serving Embedded CSS and JS Files
Author
gw1500se



Joined: 03 Dec 2014
Posts: 4

PostPosted: Sat 16 May '20 18:39    Post subject: Serving Embedded CSS and JS Files Reply with quote

I am trying write a script using python 3 httpd server. Unfortunately the documentation to that is very poor and the python forum has not been much help. Since my question is really about how data is send to the client I hope I can get some help here.

I have no trouble serving out the main page. The problem is how to serve out the embedded css and/or js files. I get the request for the files but I think my problem is I need to server them out with different headers than the main page. When the browser requests a css file, what does it expect to see as far as headers are concerned to know this is not a new page but rather the file requested? How do I know the difference between requests for a regular html page and a css or js page? It is just the file type? TIA.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7277
Location: Germany, Next to Hamburg

PostPosted: Sun 17 May '20 17:55    Post subject: Reply with quote

You may search for

Quote:
phython set http header content type
on the web.
The header for javascript files and css files is different than html
Back to top
gw1500se



Joined: 03 Dec 2014
Posts: 4

PostPosted: Sun 17 May '20 18:38    Post subject: Reply with quote

Thanks for the reply. You put me on the right track.
Back to top
dpat99



Joined: 15 May 2023
Posts: 5

PostPosted: Mon 22 May '23 10:09    Post subject: Reply with quote

Is there anyway to automatically do this so we can save time? Currently it is with separate headers for CSS / JS right?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7277
Location: Germany, Next to Hamburg

PostPosted: Wed 31 May '23 14:44    Post subject: Reply with quote

dpat99 wrote:
Is there anyway to automatically do this so we can save time? Currently it is with separate headers for CSS / JS right?


if your file has the correct file ending apache will send the correct header. It is only necessary for dynamic generated files.
Back to top


Reply to topic   Topic: Serving Embedded CSS and JS Files View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner