from django.views.generic import TemplateView

urlpatterns = [
    url(r'^test/',TemplateView.as_view(template_name='test.txt')),
    url(r'^test.txt$', TemplateView.as_view(template_name="test.txt", content_type="text/plain"), name="test")
]

访问方式:

http://127.0.0.1/test/

http://127.0.0.1/test.txt

http://127.0.0.1/test.txt

 

相关文章:

  • 2021-09-27
  • 2022-02-07
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2021-11-02
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案