Commit 0a1d0923 authored by Adrian's avatar Adrian
Browse files

cambios

parent 00272c6c
......@@ -6,18 +6,25 @@
<title>.:: Sitio ::.</title>
<link rel="stylesheet" href="./style.css">
<script type="text/javascript">
var url = 'http://localhost:5000/send';
var baseURL = 'http://localhost:5000';
function login () {
if (document.getElementById('user').value === 'admin' && document.getElementById('password').value === '123456') {
document.getElementById('login').style.display = 'none';
document.getElementById('data').style.display = 'block';
} else {
alert('Datos incorrectos');
}
service(baseURL + '/login', {
usuario: document.getElementById('user').value,
password: document.getElementById('password').value
})
.then((data) => {
if (data.finalizado) {
window.localStorage.setItem('site_token', data.datos.token);
document.getElementById('login').style.display = 'none';
document.getElementById('data').style.display = 'block';
} else {
alert('Datos incorrectos');
}
});
}
async function postData(url = '', data = {}) {
async function service(url = '', data = {}, method = 'POST') {
const response = await fetch(url, {
method: 'POST',
method: method,
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
......@@ -31,7 +38,7 @@
return await response.json();
}
function sendData () {
postData(url, {
service(baseURL + '/send', {
titulo: document.querySelector('#title').value,
text: document.querySelector('#description').value
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment