• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: The Future (ASS, ASOC, Cocoa + AS)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The Future (ASS, ASOC, Cocoa + AS)


  • Subject: Re: The Future (ASS, ASOC, Cocoa + AS)
  • From: has <email@hidden>
  • Date: Mon, 3 May 2010 16:29:06 +0100

Bruce Robertson wrote:

> Simple (or not) examples?
>
>>> Incidentally, I've started putting browser-based UIs on my workflows, rather than GUIs or CLIs, which is very easy to do in Python and Ruby - another option you might consider if your systems are server-based.
>>
>> I can vouch for the coolness of using WebKit with ASOC. You can cook up some very good looking UI with CSS3, HTML, JavaScript in a WebFrame. The HIG overlords may cringe at creating iPhone-like UIs on the Mac, but what the heck. Looks great.

Can't speak for WebKit/ASOC, but creating a basic HTTP server in Python is really simple:

#!/usr/bin/python

from BaseHTTPServer import *
from urlparse import *

class MyRequestHandler(BaseHTTPRequestHandler):

	def _encode(self, s):
		return s.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;')

	def do_GET(self):
		# process the request
		request = urlparse(self.path)
		path = request.path
		query = parse_qs(request.query, True)
		# build the response
		self.send_response(200)
		self.send_header('Content-Type', 'text/html')
		self.end_headers()
		html = '<p>%s</p>\n<p>%s</p>' % (self._encode(path), self._encode(str(query)))
		self.wfile.write(html)

HTTPServer(('', 8080), MyRequestHandler).serve_forever()

Save it to file, make it executable, and run it. This example just extracts the path and query from a URL and prints them out, e.g.:

	http://localhost:8080/foo?bar=baz

gives:

	<p>/foo</p>
	<p>{'bar': ['baz']}</p>

which should illustrate the point. POSTs are slightly different, but no harder.

No authentication or anything fancy - I would turn to a proper web framework for that - but for a modest distributed application running on an internal network that needs to pass job tickets between processes and display a basic admin UI, it's quite adequate.

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: The Future (ASS, ASOC, Cocoa + AS)
      • From: Bruce Robertson <email@hidden>
  • Prev by Date: Re: The Future (ASS, ASOC, Cocoa + AS)
  • Next by Date: Re: The Future (ASS, ASOC, Cocoa + AS)
  • Previous by thread: Re: The Future (ASS, ASOC, Cocoa + AS)
  • Next by thread: Re: The Future (ASS, ASOC, Cocoa + AS)
  • Index(es):
    • Date
    • Thread