← Back to DAGDA | Support | Source: https://gist.github.com/magicjohnson/32f2c008fa2629434dbb4e068dc34a96
Skip to content

Instantly share code, notes, and snippets.

@magicjohnson
Last active February 28, 2020 08:04
Show Gist options
  • Select an option

  • Save magicjohnson/32f2c008fa2629434dbb4e068dc34a96 to your computer and use it in GitHub Desktop.

Select an option

Save magicjohnson/32f2c008fa2629434dbb4e068dc34a96 to your computer and use it in GitHub Desktop.
Lightweight Django
#!/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