def upload():
	data = request.form
	try:
		lat, lon = float( data[ 'lat' ] ), float( data[ 'lon' ] )
	except ValueError:
		lat, lon = 0, 0
	placemark = kml.placemark( lat, lon  )
	placemark.appendChild( kml.name( data[ 'title' ] ) )
	placemark.appendChild( kml.creator( data[ 'author' ] ) )
	placemark.appendChild( kml.description( data[ 'description' ] ) )
	img = request.files[ 'file' ]
	img_id = kml.append( img.filename, placemark )
	DATA.save( img_id, img.stream.read() )
	DATA.save( 'metadata.kml', kml.metadata() )
	return placemark.toprettyxml( encoding = 'utf-8' )
Esempio n. 2
0
def upload():
    data = request.form
    try:
        lat, lon = float(data['lat']), float(data['lon'])
    except ValueError:
        lat, lon = 0, 0
    placemark = kml.placemark(lat, lon)
    placemark.appendChild(kml.name(data['title']))
    placemark.appendChild(kml.creator(data['author']))
    placemark.appendChild(kml.description(data['description']))
    img = request.files['file']
    img_id = kml.append(img.filename, placemark)
    DATA.save(img_id, img.stream.read())
    DATA.save('metadata.kml', kml.metadata())
    return placemark.toprettyxml(encoding='utf-8')
def get( img ):
	return DATA.send( img )
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU General
# Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# Learning-Week-2012-Software If not, see <http://www.gnu.org/licenses/>.

from cgi import escape

from flask import Blueprint, render_template, make_response, request

from lwf import DATA
from . import kml

img = Blueprint( 'img', __name__ )

kml.init( DATA.load( 'metadata.kml' ) )

@img.route( '/add' )
def add():
	return render_template( 'add.html' )
	
@img.route( '/metadata' )
def metadata():
	response = make_response( kml.metadata() )
	response.headers[ 'Content-type' ] = 'application/vnd.google-earth.kml+xml'
	return response

@img.route( '/upload', methods = [ 'POST' ] )
def upload():
	data = request.form
	try:
Esempio n. 5
0
def get(img):
    return DATA.send(img)
Esempio n. 6
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Learning-Week-2012-Software If not, see <http://www.gnu.org/licenses/>.

from cgi import escape

from flask import Blueprint, render_template, make_response, request

from lwf import DATA
from . import kml

img = Blueprint('img', __name__)

kml.init(DATA.load('metadata.kml'))


@img.route('/add')
def add():
    return render_template('add.html')


@img.route('/metadata')
def metadata():
    response = make_response(kml.metadata())
    response.headers['Content-type'] = 'application/vnd.google-earth.kml+xml'
    return response


@img.route('/upload', methods=['POST'])