aux.py
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import json
from validation import Validation
from flask import render_template, url_for
def answer(succ, error = None):
if succ == True:
return json.dumps({
"success" : True
})
return json.dumps({
"success" : False,
"error" : error
})
COLOR_DEFAULT = "rgb(10,10,200)"
def generate(json):
try:
if json == None:
return answer(False, "No hay datos para generar este formulario")
if 'color' not in json:
json['color'] = COLOR_DEFAULT
if 'send' not in json:
return answer(False, "No hay destino en el formulario => {'send' : 'example.com'}")
if 'title' not in json:
return answer(False, "No se ingresó título del formulario => {'title' : 'Título'}")
return render_template(
"form.html",
tabs = json['tabs'],
title = json['title'],
color = json['color'],
send = json['send']
)
except:
return answer(False, "Hay un error en los datos de este formulario")
def validate(data):
validation = Validation()
if 'url' in data:
url = data['url']
del data['url']
#r = requests.post(url, json = data)
#if r.text == "true":
if True:
return json.dumps({
'success' : True,
'cookie' : validation.make_token(),
})
else:
return answer(False,"")
return answer(False,"no validation address")