2015-08-05 11:47:49 +00:00
|
|
|
# coding=utf-8
|
2016-04-30 11:27:20 +00:00
|
|
|
import os
|
2015-08-05 11:47:49 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.http import HttpResponse, Http404
|
2015-06-26 07:59:53 +00:00
|
|
|
|
2015-08-05 11:47:49 +00:00
|
|
|
from rest_framework.views import APIView
|
|
|
|
|
|
|
|
|
|
|
|
class AdminTemplateView(APIView):
|
|
|
|
def get(self, request, template_dir, template_name):
|
2016-04-30 11:27:20 +00:00
|
|
|
path = os.path.join(settings.TEMPLATES[0]["DIRS"][0], "admin", template_dir, template_name + ".html")
|
2015-08-05 11:47:49 +00:00
|
|
|
try:
|
|
|
|
return HttpResponse(open(path).read(), content_type="text/html")
|
|
|
|
except IOError:
|
2015-08-07 12:02:08 +00:00
|
|
|
return HttpResponse(u"模板不存在", content_type="text/html")
|