Skip to content

Instantly share code, notes, and snippets.

@toastdriven
Created January 17, 2013 03:45
Show Gist options
  • Select an option

  • Save toastdriven/4553437 to your computer and use it in GitHub Desktop.

Select an option

Save toastdriven/4553437 to your computer and use it in GitHub Desktop.
import json
from itty import get, run_itty, Response
@get('/')
def index(request):
page = open('autocomplete_test.html').read()
return page
@get('/search/autocomplete/')
def autocomplete(request):
if request.GET.get('q', '') != 'hello':
data = ['hells bells', 'hello world', 'something irreverant']
else:
data = []
return Response(json.dumps({
'results': data
}), content_type='application/json')
run_itty()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment