Created
March 30, 2023 14:17
-
-
Save ermogenes/0cf5ff20802e561f72cc3254236b1c19 to your computer and use it in GitHub Desktop.
Palestra 30/03/2023 - Web App de exemplo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Logging": { | |
"LogLevel": { | |
"Default": "Information", | |
"Microsoft.AspNetCore": "Warning" | |
} | |
}, | |
"Kestrel": { | |
"Endpoints": { | |
"Http": { | |
"Url": "http://localhost:5000" | |
} | |
} | |
}, | |
"AllowedHosts": "*" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="pt-BR"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<h1>Frontend</h1> | |
<div>Vermelho = <span id="vermelho">?</span></div> | |
<div>Branco = <span id="branco">?</span></div> | |
<div>Azul = <span id="azul">?</span></div> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const atualizarPlacar = async () => { | |
const response = await fetch("/placar"); | |
if (response.ok) { | |
const result = await response.json(); | |
document.getElementById("vermelho").innerText = result.vermelho; | |
document.getElementById("branco").innerText = result.branco; | |
document.getElementById("azul").innerText = result.azul; | |
} | |
}; | |
document.addEventListener("DOMContentLoaded", async () => { | |
await atualizarPlacar(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var builder = WebApplication.CreateBuilder(args); | |
var app = builder.Build(); | |
app.UseDefaultFiles(); | |
app.UseStaticFiles(); | |
app.MapGet("/placar", () => | |
{ | |
PlacarDTO placar = new() { vermelho = 5, branco = 4, azul = 6 }; | |
return Results.Ok<PlacarDTO>(placar); | |
}); | |
app.Run(); | |
public class PlacarDTO | |
{ | |
public int vermelho { get; set; } | |
public int branco { get; set; } | |
public int azul { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div { | |
margin: 10px; | |
} | |
#vermelho { | |
background-color: red; | |
color: white; | |
padding: 5px; | |
} | |
#branco { | |
background-color: white; | |
color: black; | |
padding: 5px; | |
} | |
#azul { | |
background-color: blue; | |
color: white; | |
padding: 5px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment