• Django框架关于app解耦


    """mysite URL Configuration

    The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
    Examples:
    Function views
    1. Add an import: from my_app import views
    2. Add a URL to urlpatterns: path('', views.home, name='home')
    Class-based views
    1. Add an import: from other_app.views import Home
    2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
    Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
    """
    from django.contrib import admin
    from django.urls import path

    #form app01 import views as v1
    #from app02 import views as v2

    from app01.views import get_timer
    from app02.views import login, index
    urlpatterns = [
    path('admin/', admin.site.urls),
    path("timer", get_timer),
    path("", index),
    path("login", login),
    ]
    from django.shortcuts import render

    # Create your views here.

    from django.shortcuts import HttpResponse
    def get_timer(request):
    import datetime

    now = datetime.datetime.now().strftime("%Y-%m-%d-%X")
    return HttpResponse(now)

    from django.shortcuts import render

    # Create your views here.

    from django.shortcuts import HttpResponse

    def index(request):
    return HttpResponse("hello index")

    def login(request):
    return HttpResponse("hello login")

     

  • 相关阅读:
    kindeditor的使用
    阅读笔记(三)
    阅读笔记(二)
    架构漫谈
    阅读笔记(一)
    hdfs
    暑假周总结八
    暑假周总结七
    暑假周总结六
    暑假周总结五
  • 原文地址:https://www.cnblogs.com/A121/p/16412186.html
Copyright © 2020-2023  润新知