因为我们要用django做geoserver+openlayer的后端,所以只看get和post怎么实现就行了。
一、结构
工程结构如下图:
在新建工程的基础上,新建了一个gismap/geoserver.py;在templates中新建了两个页面get.html和post.html。
二、程序
1. geoserver.py
一共三个方法,一个是get请求,一个是post请求,一个是渲染get页面。
# -*- coding: utf-8 -*-
from django.http import HttpResponse
from django.shortcuts import render
# 接收get请求数据
def get(request):
request.encoding = 'utf-8'
if 'q' in request.GET and request.GET['q']:
messa