Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Python Making my web page publicly available

  1. Jul 29, 2017 #1
    I want to make a web page. I made it work in local network using python and Flask module. It also saves and uses data in responses, that it has got by GET and POST requests. What should I do to make it publicly available so that I had to change the original script with flask as little as possible? I want people to be able to connect it by my ip address or I could buy a domain. I am a beginner in such things and I just want to make my web page available. Could anybody teach me how to do it?
  2. jcsd
  3. Jul 29, 2017 #2


    User Avatar

    Staff: Mentor

    That's the way I would do it... :smile:
  4. Jul 29, 2017 #3
    You wont be able to provide a useful service based on the usual form of home or small business internet access.
    For one thing you need a static IP, that isn't the deal with most domestic providers, your IP can change, it's up to them.
    Even with a static IP, domestic user band width could barely support more than 3 or 4 simultaneous users.
    Yes, buy a domain, there are companies which provide that and the necessary server resources you will need at reasonable prices.
    I won't recommend a particular one, but there are some that which let you experiment for free until you have a serious site going.
  5. Jul 30, 2017 #4


    User Avatar

    Staff: Mentor

    I think in the US, most or all Internet service providers forbid residential-service customers from operating publicly accessible servers. They may even use a firewall to block outbound connections from such servers. In other countries the situation may be different.
  6. Jul 30, 2017 #5
    It is very small page (few kilobytes). I do not expect many users.

    I want firstly make it available on my ip address before buying a domain. What code should I run to make my page available on my ip address?

    Later if I buy a domain - is it then related with my ip in DNS servers and all requests to that domain are directed to my ip?
  7. Jul 30, 2017 #6
    Yes, you have the right idea about how DNS servers work.

    As jtbell pointed out though, you may find that your ISP simply doesn't provide that kind of facilty for domestic users, even though it's possible in theory.
    The way it's usually done is you get another IP, separate from your home one.
    That IP addresses a server which you have rented the use of.
    You can develop the site on your own PC, then upload it to that server when it looks all good.
    The server you use does not have to belong to your ISP, there are companies which specialise in providing server resources.
    As I said there are some who provide entry level service free, at least there were a few years ago.
    It is of course the server bandwidth and storage which you pay for, they don't physically install anything at your home.
    The physical server gear could be located anywhere in the world,
    Last edited: Jul 30, 2017
  8. Jul 30, 2017 #7
    I'd like to get more specific tips.

    I don't know if my ISP does or not. Is there a easy way to find out if it does? I prefer hosting my page from my own computer if it is possible.
    What kind of source code I need to run to host my site on my ip or to upload to hosting server if I choose to rent a server? Can you give simple HelloWorld-example? The code that I have currently written and works in local network is in python3 and uses flask module.
  9. Jul 30, 2017 #8
    I guess the customer support at your ISP will be the people to ask.
    Chances are they will try to sell you a business package that works the way I described above, by you renting some server capacity from them.
    All you actually need though is a static IP which they won't change at a whim.
    If they offer that at all, there very likely will be a price for it that's similar to the server rental approach.

    As for actually implementing a site there are different methods.
    The simplest is to write HTML fixed content pages, but that's very limiting.
    Once you have got to grips with that, you'll need to look at how HTML pages can be generated from a database, and extending beyond what HTML can do, using scriptng languages like javascript
    Last edited: Jul 30, 2017
  10. Jul 30, 2017 #9
    I have already made that with python and flask module, but It works only in local network. I do not need any script on client side.

    I do not have static IP so I will use hosting service. Most important question is that how should I modify the source code before uploading it to hosting server. Can it remain in Python?
  11. Jul 30, 2017 #10
    You will need to be assured that the server you use does in fact run Python, which is not something you can count on.
    If it does, then your program should work the same as it does for local network.
  12. Jul 30, 2017 #11
    There are some advantages to running your website on your home pc rather than using a shared hosting service. For one, you will not be limited to traditional server side scripting, such as PHP or ASP. You can do anything you want in the back-end. You can have complete and fast access to everything.

    But the two big deterrents are the security risks and your ISPs TOS. There's not a lot you can do about the former. There are steps you can take to decrease the risks, but you still have to open up your computer to the outside world. There's no way around it. As for the latter, you can try and find an ISP that allows home servers if your current one doesn't. Or your current ISP may allow it with a higher priced account.

    There's too much involved in setting up a home server for me to go into in a forum post, but there's lots of info on the web if you just do a little research. I will give you one link to get you started: https://www.boutell.com/newfaq/creating/hostmyown.html

    Also, setting up a home server is not as easy as using a hosting service. But it's a good way to learn about how the Internet works. If you have lots of time and you can manage the two deterrents I mentioned and you want to learn, then it might be worth it for you to give it a try. Otherwise, I would recommend, as the others have, that you pay for a hosting service.
    Last edited: Jul 30, 2017
  13. Jul 31, 2017 #12
    As I understood I can not run my website on my home computer, if I do not have static IP. I do not have static IP. because of that I used hosting service Pythonanywhere. The page is now available at olger.pythonanywhere.com .
  14. Jul 31, 2017 #13
    That's what many people think, but it's not true. You can use a Dynamic DNS service such as No-IP.com. However, you will have to use a subdomain of one of their supplied domain names such as yourdomain.theirdomain.com. Here's how it works, briefly: You create an account with the DDNS service, you choose a domain name, you tell it what your current IP is, you download and install their update client. The update client notifies the DDNS service whenever your IP changes and your domain name will be updated automatically to point to your new IP. This is the same way it works for security appliances such as IP cameras. It's all perfectly legal (if your ISP allows home servers). Some modem routers already include update clients in their firmware that's compatible with certain DDNS providers.
  15. Jul 31, 2017 #14
    Here's what I do with my home server:

    1. Setup dynamic DNS like TM suggested above.
    2. Configure a static IP on your internal web server (usually 192.168.x.x or 10.x.x.x).
    3. Configure your internet router/firewall to forward port 80/TCP to your internal web server's static IP.
    4. Optional for a bit of security through obscurity - Configure the firewall to listen on a random high port and redirect to the internal default port 80 - Access from outside via httx://blah.blah.blah:randomport#
    There shouldn't be any reason to modify the code, just be careful what you expose to the web so you don't get hacked.
  16. Jul 31, 2017 #15
  17. Aug 1, 2017 #16
    It is in estonian, but I will add english soon.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted