I have a web site. My webhost supports Python scripts. I am pretty good at python.

The question is:
How can i make a web-page written in python, so that after i upload it on the host server it looks just like a HTML page? (i mean, it is somehow like PHP scripting?) I have absolutely no idea how to do it.

And another question would be:
If i want to test my python-web-pages offline, just like PHP pages, what program should i use? (i checked the web, but i'm not sure, or i don't understand. Zope, Mailman, MoinMoin, PIL, Webware... ? I need something like this?)

Thank you very much.

Dani AI

Generated

A compact practical guide for and anyone who finds this thread later.

Python can absolutely produce ordinary HTML pages: the Python process writes the HTTP headers and HTML to stdout, and the web server sends that output to the browser. Which pieces need to be present on the host depends on how the host runs Python. Common hosting models are:

  • CGI (common on older/shared hosts): each request runs a script.
  • WSGI (modern standard, better performance): the app is run via mod_wsgi, uWSGI/gunicorn, etc.
  • Persistent app hosting (VPS/PaaS): the site runs as a long-lived process and serves requests directly.

pointed toward frameworks; that advice is useful—frameworks like Flask or Django sit on top of WSGI. Note that older mod_python is deprecated; prefer WSGI-based deployments (see PEP 3333).

Minimal practical steps (shared-hosting / quick start):

  • Create a CGI script with a shebang, send a Content-Type header, then HTML.
  • Make the file executable (chmod 755) and place it in the host’s cgi-bin or a location the host documents.
  • Watch line endings: files uploaded from Windows must use Unix LF on Linux hosts.
    Example minimal CGI script:
#!/usr/bin/env python3
print("Content-Type: text/html")
print()
print("<html><body><h1>Hello from Python</h1></body></html>")

Local testing and tools:

Quick troubleshooting checklist:

  • Confirm what the host actually supports (CGI, WSGI, FastCGI, SSH/VPS, or none).
  • Check Python version on the server.
  • Ensure executable bit and correct shebang.
  • Inspect server error logs for permission/path errors.

Further reading: Python CGI docs (https://docs.python.org/3/library/cgi.html), WSGI spec (https://peps.python.org/pep-3333/), and mod_wsgi docs (https://modwsgi.readthedocs.io/en/develop/).

Recommended Answers

All 2 Replies

Look into modpython, django and cherrypy.

Thank you, thank you. I checked the names you told me, but i have another problem...

I believe that these programs (django, cherry) must be installed on my computer...
And what if i have a web host and i want to write my pages in something similar to python script, make all the background calculations in Python but print the result as a normal HTML page? I am working on something very complex and i really hate PHP, though it has exactly what i need...
What should my web host have to be sure that my pages will work correctly? I mean, i want the normal user to see just normal HTML pages, with images and tables and all. Just normal HTML. But inside, this happens because of all the Python classes and functions.
I checked a few hosts that support Python... it means that i can make my script in Python and print the results as HTML or ... ?

I'm sorry, my questions are very newbie and stupid, but i don't really understand these server things...
Pleaaaaase help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.