2015-08-05 11:47:49 +00:00
|
|
|
# coding=utf-8
|
|
|
|
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):
|
2015-08-25 08:18:24 +00:00
|
|
|
path = 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")
|