Eduardo Morales
Eduardo Morales

Reputation: 843

How do I create a real Python server with a real IP?

Currently, I have developed a Chat Python app using sockets. I have the Server.py and Client.py clients. I get it to work on the localhost (127.0.0.1) but I want to take a step further and I want to be able to run a real server and have friends connect to it from their homes.

How would I do that? How do I establish the server with a real IP?

I tried to find a similar question but I wasn't able to.

Upvotes: 0

Views: 289

Answers (1)

Patrick Harris
Patrick Harris

Reputation: 325

You would have to get hosting and move the chatbot files to the server. Consider Flask or Django as python backends to deploy the chatbot.

A few steps here:

1) Get some form of hosting. Two good cheap solutions for developers are

  1. www.digitalocean.com
  2. www.linode.com

    For digital ocean you can get away for 5$ a month. Linode I think is 10$ a month.

2) Download python and your chatbot's required modules onto the server.

3) FTP your chatbot files onto the server and deploy with your framework of choice.

4) Register a domain (optional), ie https://eduardobot.com

5) Point the dns of your domain name to the ip of the server hosting your website.

Assuming you get an Ubuntu 14.04 server with Digital Ocean, the steps would be as follows

Register an Ubuntu-14.04 droplet, which will send an email containing a temporary password for the Ubuntu server

Open your terminal/command line and enter:

ssh root@server-ip-address

This will prompt you to enter a password. Now enter the password that Digital Ocean emailed to you. This will allow you to set a new password. After you've made your own, you'll be logged into the digital ocean server via ssh from your terminal.

Now enter the following commands:

sudo apt-get update
sudo apt-get -y upgrade

Once this is complete, Python 3 will be installed to the server. Confirm this by running:

python3 -V 

Now install pip to the Ubuntu server

sudo apt-get install -y python3-pip

Install your chatbot's dependencies

pip3 install Flask
pip3 install nltk
pip3 install spacy
pip3 install re
pip3 install time
...

To make sure the development environment is sufficient:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Now upload your chatbot files to your server. The easiest way to do this would is via FTP, like Filezilla or Cyberduck

Once the app was successfully running on the server, you could have your friends find the bot by the servers ip address.

If you wanted a domain name, you would just have to go into the domain's DNS after purchasing and change the nameservers to

ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com

Depending on the domain provider, you may have to provide A, cname, or other DNS records.

I'm not trying to plug digital ocean, I just use it because it's cheap. You could accomplish the same thing with any good hosting provider.

Upvotes: 3

Related Questions