URL解析:
基本格式:schema://host[:port#]/path/.../[?query-string][#anchor]
scheme 指定低层使用的协议(例如:http, https, ftp)
host HTTP服务器的IP地址或者域名
port# HTTP服务器的默认端口是80,这种情况下端口号可以省略。如果使用了别的端口,必须指明,例如 http://www.cnblogs.com:8080/
path 访问资源的路径
query-string 发送给http服务器的数据
anchor- 锚
GET方法:
views.py:
# -*- coding: utf-8 -*-
from django.http import HttpResponsefrom
django.shortcuts import render_to_response
def search(request):
if 'q' in request.GET:
message = '你搜索的内容为: ' + request.GET['q']
else:
message = '你提交了空表单'
return HttpResponse(message)
search.html:
<!DOCTYPE html>
<html>
<head>
<meta