from flask import Blueprint, render_template, request, jsonify

testsq_api = Blueprint('testsq_api', __name__)

SIZE = 64

@testsq_api.route('/test/', methods=['GET','POST'])
def test():
    block = 'none'
    return render_template('test.html', block=block)

@testsq_api.route('/refreshtest/', methods=['GET','POST'])
def refreshtest():
    data = '<svg id="svg1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1800" height="1420">'

    x = 0
    y = 0
    for i in range(0,10):
        for j in range(0,10):
            data = data + drawgridsquare(x,y)
            x = x + SIZE-1
        y = y + SIZE-1
        x = 0
   
    data = data + '</svg>'
    return data

def drawgridsquare(x, y):
    data = '''
          <rect
            fill="white"
            style="stroke:black;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
            id="switch"
            width="%s"
            height="%s"
            x="%s"
            y="%s"
    />''' % ( SIZE, SIZE, x, y)    #'''
    return data



