Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Luciano Barletta
/
mini-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit a03c9de5
authored
2019-12-16 13:06:30 +0000
by
Luciano Barletta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added a root functionality, fixed redirection bug
1 parent
cbf9c93e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
6 deletions
README.md
app.py
static/Scripts/ArmadoDeForm.js
static/Scripts/login.js
README.md
View file @
a03c9de
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
Servicio Web de generación de formularios a partir de un JSON.
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 = {
JSON = {
'title' : "Título del Formulario",
'title' : "Título del Formulario",
...
@@ -32,11 +32,28 @@ Campo = {
...
@@ -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.
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
## <myserver>/login
Formulario especial para login. Se envía solamente la siguiente información.
Formulario especial para login. Se envía solamente la siguiente información.
{
{
'color' : "Color preferido",
'color' : "Color preferido",
'send' : "MiUrl.com"
'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
\ No newline at end of file
app.py
View file @
a03c9de
...
@@ -19,6 +19,12 @@ LOGIN_FIELDS = [
...
@@ -19,6 +19,12 @@ LOGIN_FIELDS = [
]
]
JSON_FILES
=
"json"
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'
])
@app.route
(
'/load/<name>'
,
methods
=
[
'POST'
])
def
load
(
name
):
def
load
(
name
):
try
:
try
:
...
@@ -49,7 +55,7 @@ def remove(name):
...
@@ -49,7 +55,7 @@ def remove(name):
@app.route
(
'/form/<name>'
,
methods
=
[
'GET'
])
@app.route
(
'/form/<name>'
,
methods
=
[
'GET'
])
def
iform
(
name
):
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'
])
@app.route
(
'/form/<name>/<token>'
,
methods
=
[
'GET'
])
def
form
(
name
,
token
):
def
form
(
name
,
token
):
...
...
static/Scripts/ArmadoDeForm.js
View file @
a03c9de
...
@@ -129,7 +129,7 @@ function Leer(tc){
...
@@ -129,7 +129,7 @@ function Leer(tc){
function
Enviar
(
data
,
url
){
function
Enviar
(
data
,
url
){
http
=
new
XMLHttpRequest
();
http
=
new
XMLHttpRequest
();
http
.
open
(
"
GE
T"
,
url
,
true
);
http
.
open
(
"
POS
T"
,
url
,
true
);
http
.
setRequestHeader
(
"Content-Type"
,
"application/json"
);
http
.
setRequestHeader
(
"Content-Type"
,
"application/json"
);
http
.
onload
=
()
=>
{
if
(
http
.
status
==
200
)
alert
(
"Enviado con éxito"
);
};
http
.
onload
=
()
=>
{
if
(
http
.
status
==
200
)
alert
(
"Enviado con éxito"
);
};
http
.
send
(
JSON
.
stringify
(
data
));
http
.
send
(
JSON
.
stringify
(
data
));
...
...
static/Scripts/login.js
View file @
a03c9de
...
@@ -45,5 +45,6 @@ function validate(url){
...
@@ -45,5 +45,6 @@ function validate(url){
function
redirect
(
url
){
function
redirect
(
url
){
cookie
=
new
CookieHandler
;
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
\ No newline at end of file
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment