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 eb13ba84
authored
2019-11-22 09:58:10 -0300
by
Georgina Mondino
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Borrado de Archivod Iniciales
1 parent
1b8076e9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 additions
and
63 deletions
static/Scripts/construct.js → Scripts/construct.js
deploy.py
templates/generate.html → generate.html
static/
Scripts/construct.js
→
Scripts/construct.js
View file @
eb13ba8
File moved
deploy.py
deleted
100644 → 0
View file @
1b8076e
#-*- coding: utf-8 -*-
from
flask
import
Flask
,
json
,
request
,
url_for
,
render_template
import
random
app
=
Flask
(
__name__
)
TOKEN_LENGHT
=
32
TOKEN_STRING
=
"
\
1234567890
\
qwertyuiopasdfghjklzxcvbnm
\
QWERTYUIOPASDFGHJKLZXCVBNM"
sessions
=
{}
@app.after_request
def
after_request
(
response
):
# headers permitidos para la conversación
response
.
headers
.
add
(
'Access-Control-Allow-Headers'
,
'
\
Access-Control-Allow-Methods,
\
Access-Control-Allow-Origin,
\
Content-Type'
)
# orígenes permitidos para CORS
response
.
headers
.
add
(
'Access-Control-Allow-Origin'
,
'*'
)
# métodos permitidos
response
.
headers
.
add
(
'Access-Control-Allow-Methods'
,
'GET,POST'
)
return
response
def
validate
(
name
,
psw
):
if
name
==
"admin"
and
psw
==
"admin"
:
return
True
return
False
def
token
():
result
=
""
i
=
0
while
i
<
TOKEN_LENGHT
:
char
=
random
.
randrange
(
0
,
len
(
TOKEN_STRING
))
result
+=
str
(
TOKEN_STRING
[
char
])
i
+=
1
return
result
@app.route
(
'/login'
,
methods
=
[
'POST'
])
def
login
():
data
=
request
.
json
if
validate
(
data
[
'name'
],
data
[
'pass'
]):
sessions
[
'name'
]
=
token
()
return
json
.
dumps
({
"error_code"
:
0
,
"error"
:
""
,
"token"
:
sessions
[
'name'
]
})
return
json
.
dumps
({
"error_code"
:
1
,
"error"
:
"fallo en la validacion"
,
"token"
:
None
})
@app.route
(
'/'
,
methods
=
[
'GET'
])
def
main
():
return
render_template
(
"generate.html"
)
if
__name__
==
"__main__"
:
app
.
run
(
"0.0.0.0"
)
\ No newline at end of file
\ No newline at end of file
templates/
generate.html
→
generate.html
View file @
eb13ba8
<html
lang=
"en"
>
<html
lang=
"en"
>
<head>
<head>
<script
src=
"
{{ url_for('static', filename='Scripts/construct.js') }}
"
></script>
<script
src=
"
./Scripts/construct.js
"
></script>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
...
...
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