Last active
February 28, 2020 08:04
-
-
Save magicjohnson/32f2c008fa2629434dbb4e068dc34a96 to your computer and use it in GitHub Desktop.
Lightweight Django
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
| #!/bin/env python | |
| import json | |
| import sys | |
| from django.conf import settings | |
| from django.conf.urls import url | |
| from django.http import JsonResponse | |
| settings.configure( | |
| DEBUG=True, | |
| SECRET_KEY='secret key', | |
| ROOT_URLCONF=__name__, | |
| MIDDLEWARE_CLASSES=( | |
| 'django.middleware.common.CommonMiddleware', | |
| 'django.middleware.csrf.CsrfViewMiddleware', | |
| 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
| ) | |
| ) | |
| def specialties(request): | |
| with open('data_file.json') as f: | |
| data = json.loads(f.read()) | |
| return JsonResponse({'data': data['specialties']}) | |
| urlpatterns = ( | |
| url(r'^specialties', specialties), | |
| ) | |
| if __name__ == '__main__': | |
| from django.core.management import execute_from_command_line | |
| execute_from_command_line(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment