Commit a03c9de5 by Luciano Barletta

added a root functionality, fixed redirection bug

1 parent cbf9c93e
......@@ -2,9 +2,9 @@
Servicio Web de generación de formularios a partir de un JSON.
## <myserver>/
## <myserver>/load/<name>
En root se encuentra el controlador que toma el JSON y devuelve la página. El formato del JSON es el siguiente:
Aquí se encuentra el controlador carga el formulario de nombre <name>. El formato del JSON es el siguiente:
JSON = {
'title' : "Título del Formulario",
......@@ -32,11 +32,28 @@ Campo = {
Placeholder no es obligatorio. Si required no está será interpretado como False. Options es válido solo en algunos casos pero no causará error.
## <myserver>/remove/<name>
Borra el formulario de nombre <name>
## <myserver>/form/<name>
Devuelve el formulario de nombre <name> a menos que no estés logueado, en cuyo caso te envía al login
## <myserver>/login
Formulario especial para login. Se envía solamente la siguiente información.
{
'color' : "Color preferido",
'send' : "MiUrl.com"
}
\ No newline at end of file
'validation' : "MiUrlDeValidacion.com",
'redirect' : "MiUrlDeRedireccionamiento.com"
}
## <myserver>/validate
Lo usa redirect.html para validar y hacer una sesión
## <myserver>/
Te lleva al formulario por defecto
\ No newline at end of file
......@@ -19,6 +19,12 @@ LOGIN_FIELDS = [
]
JSON_FILES = "json"
ROOT_DEFAULT = "/form/default"
@app.route('/', methods = ['GET'])
def main():
return render_template('redirect.html',url = ROOT_DEFAULT)
@app.route('/load/<name>', methods = ['POST'])
def load(name):
try:
......@@ -49,7 +55,7 @@ def remove(name):
@app.route('/form/<name>', methods = ['GET'])
def iform(name):
return render_template("redirect.html",url=f"/form/{name}")
return render_template("redirect.html",url = f"/form/{name}")
@app.route('/form/<name>/<token>', methods = ['GET'])
def form(name,token):
......
......@@ -129,7 +129,7 @@ function Leer(tc){
function Enviar(data, url){
http = new XMLHttpRequest();
http.open("GET", url, true);
http.open("POST", url, true);
http.setRequestHeader("Content-Type", "application/json");
http.onload = () => { if (http.status == 200) alert("Enviado con éxito"); };
http.send(JSON.stringify(data));
......
......@@ -45,5 +45,6 @@ function validate(url){
function redirect(url){
cookie = new CookieHandler;
window.location.href = url + "/" + cookie.get("login");
if (cookie.get("login") == "") window.location.href = "/login";
else window.location.href = url + "/" + cookie.get("login");
}
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!