init
This commit is contained in:
commit
5cc0525481
8 changed files with 116 additions and 0 deletions
BIN
__pycache__/app.cpython-311.pyc
Normal file
BIN
__pycache__/app.cpython-311.pyc
Normal file
Binary file not shown.
BIN
__pycache__/app.cpython-312.pyc
Normal file
BIN
__pycache__/app.cpython-312.pyc
Normal file
Binary file not shown.
17
app.py
Normal file
17
app.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
from flask import *
|
||||||
|
|
||||||
|
app = Flask("Witze")
|
||||||
|
notes = []
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def root():
|
||||||
|
return render_template("index.html")
|
||||||
|
|
||||||
|
@app.route("/note" ,methods=["POST","GET"])
|
||||||
|
def note():
|
||||||
|
if request.method == "POST":
|
||||||
|
notes.append(str(request.data)[3:-2])
|
||||||
|
print(f"Notiz hinzugefügt: {request.data}")
|
||||||
|
return ["juhuuuu"]
|
||||||
|
elif request.method == "GET":
|
||||||
|
return notes
|
0
static/Script.js
Normal file
0
static/Script.js
Normal file
BIN
static/blume.png
Normal file
BIN
static/blume.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
static/favicon.ico
Normal file
BIN
static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
37
static/style.css
Normal file
37
static/style.css
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
a {
|
||||||
|
color: rgb(107, 214, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#body {
|
||||||
|
background-color: black;
|
||||||
|
color: chartreuse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
color: black;
|
||||||
|
background-color: chartreuse;
|
||||||
|
border-color: chartreuse;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input {
|
||||||
|
color: chartreuse;
|
||||||
|
background-color: rgb(0, 0, 0);
|
||||||
|
border-color: chartreuse;
|
||||||
|
padding: 10px;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note {
|
||||||
|
color: chartreuse;
|
||||||
|
background-color: black;
|
||||||
|
border-color: chartreuse;
|
||||||
|
padding: 10px;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 20px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
62
templates/index.html
Normal file
62
templates/index.html
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<script>
|
||||||
|
let notesdiv;
|
||||||
|
|
||||||
|
function buttonclick() {
|
||||||
|
fetch("/note",{
|
||||||
|
method:"POST",
|
||||||
|
body: JSON.stringify(notizinput.value),
|
||||||
|
headers: {"Content-type":"application/json; charset=UTF-8"}
|
||||||
|
});
|
||||||
|
notizinput.value = "";
|
||||||
|
getnotes()
|
||||||
|
};
|
||||||
|
|
||||||
|
function getnotes() {
|
||||||
|
notesdiv.innerHTML = "";
|
||||||
|
fetch("/note", { method: "GET" })
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(notesarray => {
|
||||||
|
console.log(notesarray);
|
||||||
|
for (let note of notesarray) {
|
||||||
|
console.log(note);
|
||||||
|
notesdiv.innerHTML += `
|
||||||
|
<div class="note">
|
||||||
|
<p>${note}</p>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initstuff() {
|
||||||
|
notesdiv = document.getElementById("notes");
|
||||||
|
getnotes();
|
||||||
|
//setInterval(getnotes,10000)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleKeyPress(event) {
|
||||||
|
if (event.key === "Enter") { // Überprüfen, ob die Enter-Taste gedrückt wurde
|
||||||
|
buttonclick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.onload = initstuff;
|
||||||
|
</script>
|
||||||
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Api Test</title>
|
||||||
|
</head>
|
||||||
|
<body id="body">
|
||||||
|
<h1>Notizen</h1>
|
||||||
|
<div onsubmit="" style="padding-bottom: 10px;" id="notizform">
|
||||||
|
<input onkeydown="handleKeyPress(event)" type="text" class="input" id="notizinput">
|
||||||
|
<button onclick="buttonclick()" class="button">hinzufügen</button>
|
||||||
|
</div>
|
||||||
|
<div id="notes"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue