Lets learn Python web frameworks:
Flask
When we start using flask, we will need these files.
First we install all of the required files and then use the main.py
NodeJs
You can install first and it will install all of the files mentioned in the package.json file and then you can start it.
But if you have scripts mentioned, you can start that script too.
Scripts are mentioned in the package.json file.
There are some run times which you should use instead of using node alone.
This run times will moderate nodes.For example, pm2 etc.
Install pm2
sudo npm install pm2@latest -g
Run the app.js using pm2
pm2 start app.js
IP address and ports
Once any device gets connected to a network, an IP address is assigned.
If we assign an WIFI, same thing happens.
Each of this IP has a lot of ports.
Now lets understand how a python flask works.
generally it listens to port 5000 by default but we can change it.
We have told it to listed to port 8000
But we have 2 IP addresses and both have port 8000. But we did not specify that.
We have now specified our host IP and port.
But we can set all of the host Ips by setting it to 0.0.0.0
If we dont set any Ip, it will automatically use default IP:127.0.0.1
We can also mean this 127.0.0.1 as localhost
Here you will see device 1 and device 2.
We did set our port to 8000 for device 1 and it is connected to internet. So, we can use localhost:8000 here but
if you want to use it on device 2, it won't work as device 2 is not connected to internet and we did not set anything for this device till now.
Top comments (0)