Skip to content

Instantly share code, notes, and snippets.

@sirleech
Created February 27, 2013 11:57
Show Gist options
  • Save sirleech/5047407 to your computer and use it in GitHub Desktop.
Save sirleech/5047407 to your computer and use it in GitHub Desktop.
Python REST web service in cgi bin on Apache
#!/usr/bin/python
print "Content-type:application/json"
print "Access-Control-Allow-Origin: *\r\n\r\n"
import random
import sys
import datetime
now = datetime.datetime.now()
sys.stdout.write('{"randomNumber":"')
sys.stdout.write(str(random.randint(0,500)))
sys.stdout.write('",')
sys.stdout.write('"date":"')
sys.stdout.write(str(now))
sys.stdout.write('"')
sys.stdout.write('}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment