You are not logged in.

#1 2009-08-10 13:48:34

fingfoom
Member
Registered: 2009-08-10
Posts: 2

Webinterfaces with Python

I once read "Creating a gui is much harder than creating a webinterface for your application".
While this might be true, the latter seems to be completely undocumented while there are millions of gui toolkits and tutorials.
So i read the sourcecode of some applications with webinterfaces, prominently deluge which is also written in python, but that only filled my head with acronyms like JSON, XML-RPC, SOAP, XML.
What the heck? I only need some checkboxes, inputboxes and radio groups to toggle options and set things like filenames and stuff, why do i need to know half of the newest webtechnologies to do so? And how can this be any easier than creating a gui? hmm
Searching for the subject only reveals python wikis with frameworks made for rich web applications, with database access and 100 features of which 99 i would never use.

So how would you implement a simple webinterface? Building on top of frameworks which build ontop of frameworks of frameworks? Or using features which i don't know yet?

Offline

#2 2009-08-10 14:38:59

XFire
Member
From: UK
Registered: 2008-05-11
Posts: 192

Re: Webinterfaces with Python

If it is possible, it maybe more prudent to use PHP opposed to Python.


There is a difference between bleeding [edge] and haemorrhaging. - Allan

Offline

#3 2009-08-10 14:45:06

g0ju
Member
From: Chemnitz, Germany
Registered: 2009-08-08
Posts: 23

Re: Webinterfaces with Python

I think you should take a look at python's cgi module. It looks pretty simple and seems to be what you want.

Offline

#4 2009-08-10 16:17:52

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Webinterfaces with Python

The GUI in a webapp is pure XHTML. Json, AJAX and the other things can improve the interaction, but the actual layout is donew ith XHTML and CSS.

The easiest python backend for a simple webapp is probably web.py. w3schools has the best tutorials on XHTML and CSS. Google has links to both. Have fun!

Dusty

Offline

#5 2009-08-10 16:29:10

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Webinterfaces with Python

Whether you use PHP or Python or whatever (personal, but I favor PHP), you will be brainwashed by all those acronyms soon or later.  You need those if you want to look cool...  the more thechnologies you use, the more vulnerable you can become or less chance one can benefit from the added features if behind a very restrictive firewall.

But first, you have to know the basics of hmtl.  I assume you do.  Then you can improve the view with CSS.  And then go wild with all the others.

Offline

#6 2009-08-12 15:20:36

fingfoom
Member
Registered: 2009-08-10
Posts: 2

Re: Webinterfaces with Python

The application is written in python, so how would php fit in?
I think you misunderstand me Dusty (or i just used the wrong words), i don't want a webapplication. I know Django can be used for such things if you're into python, but thats ment for things like flickr or such stuff. I only need a frontend for a local running daemon, like a bittorrent application.
It's like Daemon -> xxx -> Browser
But im missing the link and i have no clue how a webframework of which some even need an external webserver like apache could be used for something like that.
Im studying the transmission sourcecode right now, but not with much success.
HTML, CSS and JS is not the Problem, i know these.

Offline

#7 2009-08-12 16:43:26

alterecco
Member
Registered: 2009-07-13
Posts: 152

Re: Webinterfaces with Python

fingfoom wrote:

It's like Daemon -> xxx -> Browser
But im missing the link and i have no clue how a webframework of which some even need an external webserver like apache could be used for something like that.

The problem is that the xxx area is rather involved. You will need some form of server that your browser can interact with over port 80 (or whichever you require), and which in turn can pass requests to your application, which after processing the request will return some HTML (with potential css and javascript added on). Your choice of server can vary from apache to a home built one. I would personally recommend you take a look at the server provided by the 'paster' project. It is used as the development webserver for pylons, but is standalone (ie, it does not require you to build your app with pylons). When it comes to python and serving html to a browser, you should aquiaint yourself with the WSGI spec.

.]

Offline

#8 2009-08-12 22:10:28

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: Webinterfaces with Python

Perhaps if you explained in a little more detail what you're trying to achieve here...  you have a daemon running on your system, and you want to write a client program that interacts with it, right?  And instead of writing a GUI app, you want to write a webapp to do that (presumably so you can access it remotely)?

So, you write a Python script that takes input from an HTML form, does something with it, communicates with the daemon, and prints the results (as HTML) on stdout.  Then you write the HTML form and point it at your script.  When you go to the form in your browser and click "Submit", it calls your CGI script with the given parameters, and gives you back the results.  No?

Edit:  You can use a simple server that comes with Python for testing.  "python /usr/lib/python${version}/CGIHTTPServer.py", then surf to localhost:8000.

Last edited by Trent (2009-08-13 15:13:32)

Offline

#9 2009-08-12 22:24:59

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Webinterfaces with Python

Pyther should weigh in on this thread, he wrote such an app using web.py for a recording project. I'll try to find him.

Dusty

Offline

#10 2009-08-17 02:35:49

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: Webinterfaces with Python

As Dusty said I wrote an application that would call a recording script that I wrote. I had a form that asked the user for a filename, time, etc... Then I passed that into POST() which analyzed the settings and ran the script.

Now I'm not sure what you are looking to do here. It seems like you want to write some type script to control the daemon and then in the webapp you would call the script which controls the daemon.

I hope this helps!


Website - Blog - arch-home
Arch User since March 2005

Offline

Board footer

Powered by FluxBB