• Django之 HelloWorld


    1、C:Usersandy>django-admin startproject sundyblog   ## 创建项目
         C:Usersandy>cd sundyblog
    2、C:Usersandysundyblog>python manage.py startapp blog ##创建模块
    3、编程 (编辑 views.py 与 urls.py)
    4、C:Usersandysundyblog>python manage.py migrate         ##生成sqlite数据库
    5、C:Usersandysundyblog>python manage.py runserver    ## 启动服务

    过程效果图:

    views.py: ## 地址访问返回结果

    from django.shortcuts import render
    from django.http import HttpResponse

    # Create your views here.
    def hello(request):
    return HttpResponse('<h1>Hello Sundy</h1>')

    urls.py: ## url 绑定返回结果

    from django.conf.urls import include, url
    from django.contrib import admin

    urlpatterns = [
    # Examples:
    # url(r'^$', 'sundyblog.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^blog/$','blog.views.hello'),
    url(r'^admin/', include(admin.site.urls)),
    ]

    访问效果图:

    浏览器输入 http://localhost:8000/blog/

  • 相关阅读:
    Using NAT between the vCenter Server system and ESXi/ESX hosts (1010652)
    Zabbix监控windows进程连接数
    CentOS yum [Errno 14] problem making ssl connection CentOs
    httpSecurity
    Nginx
    线程基础知识
    SqlServler
    关于数据库索引
    Https的底层原理
    Synchronized
  • 原文地址:https://www.cnblogs.com/andy6/p/10365782.html
Copyright © 2020-2023  润新知