Displaying Python on the Internet

In summary, the conversation discusses using Python for web development and the limitations of free web hosting services. It is suggested to install a webserver and use Python to create dynamic web pages. PHP is also mentioned as a popular choice for web development. It is recommended to start with simpler programming tasks before tackling web development.
  • #1
wScott
88
0
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:
 
Technology news on Phys.org
  • #2
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
 
  • #3
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
 
  • #4
Well Chroot, to answer your first post I wasn't thinking of making a big impact or whatever just making my website 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 website 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:
  • #5
wScott said:
Well Chroot, to answer your first post I wasn't thinking of making a big impact or whatever just making my website more dynamic, like you said, by adding things like input output and things like that.

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

EDIT: On the website 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.

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
 
  • #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?
 
  • #7
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
 
  • #8
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 across 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.
 
  • #9
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/
 

1. How can I display Python code on my website?

One way to display Python code on your website is by using a code embedding tool, such as GitHub Gists or CodePen. These tools allow you to paste your code and embed it as a snippet on your website. You can also use a code highlighting library, such as Pygments, to make your code more visually appealing.

2. Can I use Python to create dynamic web content?

Yes, you can use Python to create dynamic web content by using a web framework like Django or Flask. These frameworks allow you to build web applications with Python that can generate dynamic HTML pages, handle user input, and interact with databases.

3. How can I integrate Python with HTML and CSS?

You can integrate Python with HTML and CSS by using a templating engine, such as Jinja or Django templates. These engines allow you to mix Python code with HTML and CSS to create dynamic web pages. You can also use a CSS preprocessor like Sass or LESS to style your web pages.

4. Is it possible to deploy a Python web application on a web server?

Yes, it is possible to deploy a Python web application on a web server. You can use a web server like Apache or Nginx to serve your application, along with a web application server like Gunicorn or uWSGI to handle the application logic. You can also use a platform-as-a-service (PaaS) provider like Heroku or PythonAnywhere to deploy and host your application.

5. What are some best practices for displaying Python on the internet?

Some best practices for displaying Python on the internet include using a virtual environment to manage dependencies, following PEP 8 coding style guidelines, and properly documenting your code. It is also recommended to use version control, such as Git, to track changes and collaborate with others. Additionally, regularly updating your code and testing it before deploying it can help ensure a smooth and efficient web application.

Similar threads

  • Programming and Computer Science
Replies
10
Views
2K
Replies
6
Views
651
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
5
Views
994
  • Programming and Computer Science
Replies
4
Views
885
  • Programming and Computer Science
Replies
1
Views
688
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
2
Replies
55
Views
4K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
2
Replies
47
Views
3K
Back
Top