Live data from Hacker News

I only know PHP. How do I write a Web application in Python?

me.veekun.com

61–70 of 196 posts

Re: I only know PHP. How do I write a Web application in Python?

#61
post #51
post #7

"MySQL is the PHP of databases". Strange, I just had this sentence popping in my head yesterday. I'm seriously considering writing a list of its wrong doings. Great article overall.

Color me as another interested specimen.

I wanted to do that now but did some lego with my kid instead, will keep you 3 informed when done.

Re: I only know PHP. How do I write a Web application in Python?

#62
post #59

I have no idea why web2py gotten such a bad rep. I am a beginning webdeveloper and seriously: web2py is a pleasure to work with. Simple to start, deploy, port and hack. It's backwards compatible and has a template language that really is non existant as so far as its pure python. Compare that to Rails - which is (comparable) hell to set-up and breaks with upgrades etc. If you want python web development to be simple,…

> But I don't think so. One of the reasons for this is that Jakob Moss removed his web2py bashing from this thread. Didn't edit - removed it: https://www.quora.com/Is-web2py-a-good-Python-web-framework/... . What did he remove? https://www.quora.com/Is-web2py-a-good-Python-web-framework/... This isn't the first instance of Django/Flask people not agreeing with web2py design and implementation, and they have been voca…

Sorry - I remembered that I on an earlier occasion couldn't find JKM' answer. It's there now - and I personally don't find it convincing. Again - I am a novice and has no authority here. – I'd edit above if I could. I am sorry that I wrote wrong info.

Thanks for the reddit link. As you say it seems to me most of the flak is from not agreeing on something. But can an oppinion be correct?

And yes: Mitsuhiko seems to be a super cool, clever and friendly guy. In my last project I played around with request. Lovely it was.

Anyways: my point was not to express that web2py is the greatest thing invented since bacon. Only that I don't understand why the python community dislike it so. After all - web2py makes it very easy to build stuff. Hence it will probably attract people to the language. Hence make it more feasible for webhosts to offer python friendly environments. And that should be a good thing? Especially in the context of OP - "how do PHP guy start with python"?

Re: I only know PHP. How do I write a Web application in Python?

#63
post #52
post #10

I'd say the necessity of this post is why PHP is as popular as it is. With PHP, there are no package managers I have to install; there is no template language to learn; there is often no version control; there is no "framework"; etc. You just drop in a .php file and, most likely, it will just run. If I need a quick dynamic page on my server, it's much easier to do this in PHP than in Python or Ruby. Until Python or R…

CGI scripts have much of PHPs simplicity. You can just drop in a executable file, and depending bit on server configuration, it will just run. With Python a basic hello world would look something like this: #!/usr/bin/python print "Content-type: text/plain" print "" print "Hello World!" So 3 lines of "boilerplate", and then you can do anything you want. No extra packages to install or languages to learn. No framework…

It's a good point that of course python web apps don't have to be complicated. But what you're describing is also not the same as PHP.

Re: I only know PHP. How do I write a Web application in Python?

#64
post #8
post #3

Say wat you want of php. But it's (insert personal pejorative option) made for it. Sure Its a_little_inconsistent AndSomewhatChaotic But all the basics for the web are incredible accessible right away. With every other language you have to start with a framework. I find php easier than rails to prototype applications and do fast hacks that need a web face. It's simply the right tool for the job on those occasions. Of…

That's a nice sentiment that's completely inaccurate. Even 6 years ago when I first started programming Python, simple Python cgi scripts were very easy to write. It's as simple as: print """\ Content-type: text/html ... """ With %(var)s interpolation, you can even slap in locals() easily to trivially put variables' values into the page.

That doesn't seem like it will scale very well at all. Or am I missing something?

Re: I only know PHP. How do I write a Web application in Python?

#65
post #50
post #26

Earlier quoted context omitted.

It's a chicken-and-egg problem. Best I can do is encourage more people to write more Python software, so those crappy free hosts are more inclined to support running it. Until then, I don't think it's terribly unreasonable to pay twenty bucks a month for a server to play with. That's less than AT&T wants to charge me for sending a thousand 160-byte messages.

Don't mess with "crappy free hosts" -- just run it on a free Heroku dyno ( http://www.heroku.com/pricing ). Kenneth ( http://kennethreitz.com ) shows you can get good performance with Flask on the free dyno ( http://flask.pocoo.org/mailinglist/archive/2012/2/22/flask-o... ).

That's a fair bit more involved than "FTP files to my web host and they usually just work"

Re: I only know PHP. How do I write a Web application in Python?

#66
post #65
post #50

Earlier quoted context omitted.

Don't mess with "crappy free hosts" -- just run it on a free Heroku dyno ( http://www.heroku.com/pricing ). Kenneth ( http://kennethreitz.com ) shows you can get good performance with Flask on the free dyno ( http://flask.pocoo.org/mailinglist/archive/2012/2/22/flask-o... ).

That's a fair bit more involved than "FTP files to my web host and they usually just work"

It's actually easier...

  $ git push heroku master

Re: I only know PHP. How do I write a Web application in Python?

#67
I was thinking this could redeem the author's credibility a little after the PHP rant, but the irrational hatred for Cheetah sounded very familiar.

I only used it in one project, a few years ago, but there's really no bad thing about it I couldn't say about any other templating system in any language I ever tried.

I wouldn't really take offense with that, but while the XSS chapter still has some points, the Sanitizing chapter goes on to bash PHP for a subjective trend of sanitizing (examples?) just to go on and present an example of sanitizing.

In general, it was a decent article, but sadly again much more opinionated than needed. It's one thing to suggest one technology over the other but it doesn't help to make people who actually agree with your point have their eyes rolling every second paragraph. (That the author doesn't like MySQL was to be expected after the PHP rant as it usually goes hand in hand, but showing some real reasons for Postgres over MySQL would have been nice.)

Still the same criticisms apply, I'd wager most people use PHP (or MySQL for the matter) because it's MINDBLOWINGLY AMAZING, but because a) the infrastructure is set up (especially DBAs hate to mix and match in my experience) b) the people at hand can use the language and use it well c) it gets the job done. quickly. sometimes "good enough".

Re: I only know PHP. How do I write a Web application in Python?

#68
post #66
post #65

Earlier quoted context omitted.

That's a fair bit more involved than "FTP files to my web host and they usually just work"

It's actually easier... $ git push heroku master

Sure, well I would hope it's easy to do a one line deploy to any platform and with any language... once you set it up. You left out freezing requirements for pip, setting up cedar, etc. Nothing like that for a simple PHP app.

I don't want to overstate the case; deploying Flask isn't hard, but deploying PHP is stupidly easy.

Re: I only know PHP. How do I write a Web application in Python?

#69
post #18

Earlier quoted context omitted.

What frameworks and platforms would you recommend for web development with java? I am writing my senior project at college in java (mainly because of the wide amount of image processing libraries available) and would love to add web capabilities.

I tend to prefer Python/Flask for Web dev to Python but if you are inclined to use Java there's only really one framework that doesn't make me want to tear my eyeballs out. That framework is Spring MVC. It is DI, adapters for vendor-specific libraries and utility. It's probably not the easiest thing to start with just because it is so flexible that it can be hard to know where to start. A good "Hello World" Spring MV…

Grails (grails.org) is Spring under the hood, good MVC layer on top, and gives you Java or Groovy wherever you want to use it. For people coming from a dynamic language background (php, python, ruby, etc) I've found that Grails is a good middle ground option.

Re: I only know PHP. How do I write a Web application in Python?

#70
post #64
post #8

Earlier quoted context omitted.

That's a nice sentiment that's completely inaccurate. Even 6 years ago when I first started programming Python, simple Python cgi scripts were very easy to write. It's as simple as: print """\ Content-type: text/html ... """ With %(var)s interpolation, you can even slap in locals() easily to trivially put variables' values into the page.

That doesn't seem like it will scale very well at all. Or am I missing something?

PHP doesn't scale well either. You can rewrite for scaling later.
Post reply on HN