Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Meanwhile, Python comes already installed by default in most linux distributions. So, forget .ini files, forget apache until deployment time(hell, don't be forced onto apache if you don't want to. Choose whichever deployment server you want. I know... options... it's weird... you'll get used to it), forget worrying about php upgrades on shared machines, forget that apt-get line. .py file, and you're up and running (and headache-less).


I have a fresh install of such a distro, where Python is included. What do I need to do to from Python present an input form which takes my name and a second page that greets me using the same name? Including deployment of course, how else should I test it without paying a web host?

I'm not discussing headaches, I do nit particularly like PHP. My point is just that Python is not very easy to get started with for beginners.


  import web
          
  urls = (
      '/(.*)', 'hello'
  )
  app = web.application(urls, globals())
  
  class hello:        
      def GET(self, name):
          if name: 
              return 'Hello, ' + name + '!'
          else:
              return "<form><input name='name'></form>"
  
  if __name__ == "__main__":
      app.run()
upload into your web server's cgi-bin folder, or have the server configured to exec all *.py files as python

ED> yeah, this is a few more lines of code than PHP and it requires a teeny tiny amount of knowledge about how the web works - and that "takes 5 minutes to get started" vs PHP's "takes 2 minutes to get started" is a big difference for someone who doesn't know what they're doing but wants results immediately :P

EDED> Actually now that I think about it, that's how /I'd/ start a simple webapp as it has the structure in place to grow easily and elegantly -- if you're willing to do things the quick and dirty way, you can go without a framework and just print an HTTP response to stdout - in which case the only difference with PHP is that the python version requires "print 'Content-type: text/html\n'" at the top


I certainly do agree that this somewhat more abstract approach is much better for stable web applications. My point is that PHP doesn't require you to understand anything to get started, which explains its widespread usage. That is of course not true if you want security or maintainability, but that is exactly the snake oil sold by PHP.

But this web framework is much newer than PHP, isn't it? And this does not look better or easier than PHP: https://wiki.python.org/moin/CgiScripts


> And this does not look better or easier than PHP: https://wiki.python.org/moin/CgiScripts

That has tracebacks on error and HTML escaping, so I'd say it's considerably better for a tiny increase in difficulty (but you're right that no matter now tiny the difference, PHP is still easier)


I think your missing the point, what comes in a Linux distribution is irrelevant. What comes installed from a hosting company is what matters, and since PHP is easy for a SysAdmin to install it was installed. Choice is often limited by the host.


Most hosts out there offer linux as their main platform? Plus, installing python with apt-get is not much more difficult than php. One liner, minus the .ini configuration stuff.


"apt-get is not much more difficult than php"

Nope, I install PHP and then upload a page with PHP embedded and it works. It is not that easy with python. That's why all these hosting accounts had LAMP and not something else.


What happened to context? The guy above me clearly said he used apt-get to install php. You're gonna have to install php somehow, whether you're gonna use apt-get or not is your decision, but whichever way you choose, apt-get or make, the difficulty is about the same.


The difficulty isn't the same because installing python doesn't install any web server integration. That's the point.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: