How to run a Dynamic website with a http server - javascript

I am trying to run a dynamic webpage on my pc using a html server.
I have a website that needs to access jquery through a CDN however I cant do this normally as Chrome doesn't let me because of CORS policy.
I did some research and found that I could use python to start a http server with python http.server.However, this only works for static webpages.
How do make a dynamic http webserver.
Any help would be appreciated.
Thank you very much.
I have tried using python http.server however this only works for static pages and i need something that works for dynamic pages.

I just found out you can download an extension in visual studio code that does this.
Thank you so much for the suggestions.

Related

Not allowed to load local resource problem?

i'm trying t use Backpack React Scripts but it won't run the local resource,
i tried to change the DNS server and use web server for chrome but it did't work
any help please?
i'm trying t use Backpack React Scripts but it won't run the local resource,
i tried to change the DNS server and use web server for chrome but it did't work
any help please?

Is there a way to implement IPC to a HTML5 web browser (served using LAMP server)?

Forgive me if this is a silly question but I could really use advice on the direction to look at for a project I am working on.
I made a webserver that streams RTSP to a webpage using LAMP, php and mysql; and served a html template. This was done on a raspberry pi and it all works fine as is. Also done on an Ubuntu VM.
EXAMPLE I FOLLOWED: https://www.thewebblinders.in/programming/article/rtsp-streaming-on-a-web-browser-6069
The next part of my project was to add buttons to the html page, that when pressed send a universal protocol command. I found that I needed to do this using IPC (inter-process communication) however I'm not really sure how to implement this to what I have now.
At the moment my system works simply as a html webpage that is served from /var/www/html using npx http-server --cors (from the open source server environment NODE.js)
I'm not really sure how I could implement a python or javascript back end that communicates to something like electron.js (I tried the latter method but had no success).
Would it be a separate program that acts as a server that hosts the html page instead of Node.js? Would I still keep my templates and methods in the LAMP src directory (/var/www/html)?
Any advice on the possible direction I could look at would be a lot of help. I've not found much online that discusses IPC work on html templates served by node.js. The only html related topic I've seen relating to it is JavaScript with electron.js and that changes the way my webserver is ran.
Thanks for taking the time.

How to fix javascript problem in 000webhost

I developed a website for a school project and locally on my PC, it works like a charm! the CSS and JavaScript are perfect and the website is very fluid and dynamic.
when i uploaded it to 000webhost, the website works well except for the JavaScript. the carousel images, sliders, etc are static and don't move.
The JavaScript is coded into each HTML file using <script></script> tags, and is not a separate .js file.
It works perfectly when its run locally and this problem only occurs when i run it from the web host.
Please view the website and assist anyhow possible, it will be much appreciated.
https://dut-it-tutors.000webhostapp.com/index.html
thanks.
You're loading the jQuery library from a CDN without https enabled. As your site is hosted using https the browser blocks the request to your non-https resource because of mixed content.
To fix this load jQuery from a CDN over https.
Just simply check the spellings of the file name.
'<script src="./userLogin.js"></script>'
is wrong when the actual filename is
<script src="./userlogin.js"></script>
check for upper and lower cases

How can I edit a js file sent by the server before it gets to my browser?

During a normal browsing session I want to edit a specific javascript file before the browser receives since once it gets there it's impossible to edit. Is there are any tool for this? For what I need it I can't just save it and edit it on my disk.
I'm ready to learn how to program it myself but if anyone can point out more or less what I have to do I'd be very grateful. I'd have to intercept the packets until I have the whole file while blocking the browser from receiving it any part of it, then edit it manually and forward it to the same port.
I don't think I can do this by just using pcap, I've read a bit about scapy but I'm not sure if it can help me either.
Thanks in advance.
You'd need to implement some sort of proxy, or hook into an existing one, and intercept the file as it's being downloaded and replace it.
Not trivial for a beginner, but a good learning project.
If you are happy to, rather then editing a file, replace it with a local one, then I would* use Charles and its Map To Local function.
Actually, "did". This helped me debug a problem with a browser and a JS file I couldn't edit yesterday.
You can probably achieve whatever it is you are wanting to do by using the firefox firebug plugin, chrome's development tools or the firefox greasemonkey plugin.
Or you could enter the files domain into your hosts file and point that domain to your local machine (running a web server), edit & save that javascript file locally and serve it from your own web server.

Double-Click HTML files and JQuery

I noticed that when I open HTML file locally by double clicking on it, it will not "run" the same as if I had it on a web server and opened it by HTTP GET request.
I need to have a local HTML file a user can open by double clicking on it. This HTML file has several JQuery load calls such as this:
$("#content").load("http://somepage.com/index.html");
I want to update several divs with content from remote sites.
This works fine If I have this file on a web server but not if I double click it under windows explorer... How can I "make" the file "run" as it would on a web server?
I think you pretty much cannot. This has to do with domain-access restrictions, which are there to avoid cross site scripting and the likes.
The files on your hard drive are especially limited - think what the life could be if they were allowed to treat your whole hard-drive as a single domain.
If you want things to work properly you need to be running a server. XAMPP is a pretty good bet as it's easy to install and set up.
Any non-AJAX javascript will work fine as is though, as long as the paths to include any css or js are relative.
You can't do this locally. You have to have it hosted somewhere for this to work. It's done this way for the sake of security.
What are you trying to do that you "need" to have this?

Categories