I am a beginner in this field, and Google search of my question was of no help.
I am planning on learning the basic first using Python SimpleHTTPServer and simultaneously start poking around in Node.js. Is that possible in my local PC? Is there any restriction on having one server installed at a time?
I am sorry if this is a silly question but like I said, I have very little knowledge in this field.
2 Answers
Yes you can do that. Only thing you need to take care of is the port numbers. 2 services can't run on the same port. Example, if you python server is running on port 80 then run your nodejs server on port 81 or whatever you want.
Here's simple code for that: Python
flask run --host=0.0.0.0 --port=80Node:
server.listen(1231);Now you will have 2 HTTP servers running at the same time on 2 different ports and both of them won't interfere in each others operation until you code them to do so.
An HTTP server is "bound" to a port. When you connect to a server you connect via a IP address and a port number. This can be confusing for the beginner because the port number defaults to 80 for http and 443 for https, so the beginner can be unaware that it matters.
If you want to have more than one http(s) server running at the same time, you need to bind them to different ports. Common ports for binding alternative servers to include 8080, 8888, etc.
Check the documentation for the server in question and when you start the server, bind it to an alternative port. Then when you need to connect to the server from your browser, simply designate the port to connect to like: