//djdemo1\urls.py
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static,serve
from django.views.generic.base import RedirectView
from django.urls import path,re_path
urlpatterns = [
# 匹配a3/re/任意数字 和 a3/re/ , 不匹配 a3/re/1/2
re_path(r'a3/re/\d*$', a3v.re_int),
# 匹配a3/re/任意大小写字母 ,不匹配 a3/re/ 和 a3/re/a/b
re_path(r'a3/re/[A-Za-z]+$', a3v.re_alphabet),
# 匹配a3/re/任意字母数字/任意字母数字/****
re_path(r'a3/re/.*$', a3v.re_all),
path('favicon.ico', RedirectView.as_view(url=r'media/favicon.ico')),
# path('favicon.ico', RedirectView.as_view(url=r'static/img/1.jpg')),
# 设置用户上传文件的路径可访问,展示服务器图片的路径可访问
re_path(r'^media/(?P<path>.*)$', serve,{'document_root':settings.MEDIA_ROOT},name='media'),
]
//app3\views.py
****************
def re_int(request):
return HttpResponse('re_int')
def re_alphabet(request):
return HttpResponse('re_alphabet')
def re_all(request):
return HttpResponse('re_all')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。