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

Displaying Python on the Internet

  1. Mar 21, 2006 #1
    Can someone tell me how you would apply python to a web document. Like add the python code to a geocities.com account?
    I'd like to know that I can publish Python for all to see :smile:
     
  2. jcsd
  3. Mar 21, 2006 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Many people use Python on websites, but the Python is running on the server, not on the client. You can use Python to make a page dynamic (perhaps it changes everytime you view it, like this forum).

    Unfortunately, geocities (and other free webspace providers) won't let you run your own custom-written programs on their servers, since it would constitute a security risk.

    My suggestion, if you're willing to do a bit of learning, is actually to install your own webserver, and serve your own site from your own PC. You can install apache (a webserver) and modpython (the plugin which allows apache to run Python programs) even on a Windows machine, I believe.

    If you want to show your dynamic, Python-powered website to the world, there are some subtleties -- for example, if your IP address changes often, you'd have to use a dynamic DNS service.

    However, wScott, I strongly recommend that you don't start your career in Python by trying to develop web software. Instead, I suggest you start with command-line programs, then work your way up to desktop GUI programs, then move on to web applications.

    - Warren
     
  4. Mar 21, 2006 #3

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Actually, let's talk about this a bit. Maybe I can whet your apetite. :smile: Have you downloaded and installed the Python distribution from http://www.python.org/ yet?

    - Warren
     
  5. Mar 21, 2006 #4
    Well Chroot, to answer your first post I wasn't thinking of making a big impact or whatever just making my web site more dynamic, like you said, by adding things like input output and things like that.

    To answer your second post, I have indeed downloaded it and I'm going through it a little at a time, going through the examples they show me in the tutorials and trying my own things. By the way, do you think it would be a good idea to take notes from the tutorials and putting them in a notebook while I work through it?

    EDIT: On the web site it shows Python as an Object Object Oriented programming language, yet I haven't run into what I expected, not like the microsoft visual basic I'm being taught in school.
     
    Last edited: Mar 21, 2006
  6. Mar 21, 2006 #5

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Well, as I said, you'll need more than just a goecities account to do web stuff with Python (or any other language), unfortunately.

    Python indeed has very powerful (and syntactically clean) object orientation. However, unlike other OO languages like Java, there's no obligation to use object orientation. Your first programs will probably be more like scripts. What were you expecting?

    - Warren
     
  7. Mar 21, 2006 #6
    To be honest I don't know hwta I was expecting the first time I downloaded it. I guess a bit like MS Visual Basic :p.

    Out of curiosity, if I made like a test site from notepad could I put my Python into that to test it out?
     
  8. Mar 21, 2006 #7

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Python is pretty far removed from Visual Basic. Given a choice between the two, Python is a much more powerful and widely accepted language.

    Again, the only way to get Python in a website is to have access to a web server which you can use to run your Python code. The output from your Python code would then be sent to the client's web browser. You can't embed Python in a web page itself, because web browsers cannot execute Python.

    If you'd like, you can install apache on your local computer, then run your Python programs through it. You're going to need full access to some webserver, either your own or someone else's, to run Python-based web applications.

    I can guide you through the installation if you need me to.

    - Warren
     
  9. Mar 22, 2006 #8

    -Job-

    User Avatar
    Science Advisor

    If you only want to develop web applications then you have the choice of Python, PHP, ASP/ASP.NET, JSP, CGI, etc.. There's plenty, PHP arguably being the most popular.
    I went to Geocities and i saw that of the two packages "Plus" and "Pro", "Plus" doesn't support any server-side technology, but "Pro" has support for PHP and CGI and provides you with MYSQL database.
    CGI programs can be built with any language, C, JAVA, Python... So you have plenty of options here if you get the "Pro" package.
    From a web development perspective i would recommend PHP over python running as CGI because PHP is built for web development, and is supported accross more web hosts, and because i magine there is some overhead in running an application as CGI rather than on a server running the appropriate server extension. But either one will accomplish what you want to do.
     
  10. Mar 22, 2006 #9

    -Job-

    User Avatar
    Science Advisor

    I also recommend you run your own local webserver, it's very rewarding and it gives you full control over what you want to do.
    Finally, a good web development reference is:
    http://www.w3schools.com/
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Displaying Python on the Internet
  1. Error on Python (Replies: 9)

  2. Chess with Python (Replies: 2)

  3. Is Python the future? (Replies: 10)

  4. Python installation (Replies: 10)

Loading...