python框架-Django创建项目
2021-07-16 07:05
标签:设置 运行 cut tar types python iter settings ssi 在douban文件夹下 2. 3. 4.运行 python框架-Django创建项目 标签:设置 运行 cut tar types python iter settings ssi 原文地址:https://www.cnblogs.com/zhuzq/p/9534746.html创建项目
django-admin startproject douban
//创建projectcd douban
python manage.py startapp books
//创建app项目配置文件
1.vim books/views.py
//写入页面程序# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def hello(request):
return HttpResponse("hello douban!!")
vim douban/urls.py
//修改路由from django.conf.urls import url
from django.contrib import admin
from books import views
urlpatterns = [
url(r‘^admin/‘, admin.site.urls),
url(r‘^hello/douban/$‘,views.hello),
]
vim douban/settings.py
//修改基本设置INSTALLED_APPS = [
‘django.contrib.admin‘,
‘django.contrib.auth‘,
‘django.contrib.contenttypes‘,
‘django.contrib.sessions‘,
‘django.contrib.messages‘,
‘django.contrib.staticfiles‘,
‘books‘//添加books项
]
python manage.py runserver
在浏览器访问http://127.0.0.1:8000/hello/douban/
返回hello douban!!!即可
上一篇:C++下遍历文件夹
下一篇:Python 爬取简单网页
文章标题:python框架-Django创建项目
文章链接:http://soscw.com/index.php/essay/105920.html