Created
January 17, 2013 03:45
-
-
Save toastdriven/4553437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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