If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

The code is based on work by Gustavo, he used webpy

import mapscript
import os

def wxs():    
    path_map = os.path.join(request.folder, 'private', 'test2.map')    
    if not request.vars:
        return ''
    req = mapscript.OWSRequest()
    for v in request.vars:
        req.setParameter(v, request.vars[v])

    map = mapscript.mapObj(path_map)
    mapscript.msIO_installStdoutToBuffer()
    map.OWSDispatch(req)

    content_type = mapscript.msIO_stripStdoutBufferContentType()
    content = mapscript.msIO_getStdoutBufferBytes()  
    response.header = "Content-Type","%s; charset=utf-8"%content_type
    return content

This service can be consumed by QGis (or another client WMS or WFS)

In QGIS url parameter is set to: http://localhost:8000/mapas/default/wxs/

More information

Comments (0)


Hosting graciously provided by:
Python Anywhere