Skip to content
Snippets Groups Projects
Commit f0a76806 authored by Karl-Luca's avatar Karl-Luca
Browse files

webinterface1.0

parent 210ab0e9
No related branches found
No related tags found
1 merge request!5Raspberry
.DS_Store 0 → 100644
File added
File added
from flask import Flask
app = Flask(__name__)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 11 10:52:31 2023
"""
#import RPi.GPIO as GPIO
from flask import Flask, render_template, redirect, url_for, request
import datetime
app = Flask(__name__)
app.config["TEMPLATES_AUTO_RELOAD"] = True
@app.route('/login', methods=['GET', 'POST'])
def login():
error = None
if request.method == 'POST':
if request.form['username'] != 'Projektname' or request.form['password'] != '123#':
error = 'Invalid Credentials. Please try again.'
else:
return redirect(url_for('hello_world'))
return render_template('login.html', error=error)
@app.route('/')
def hello_world(): # put application's code here
return 'Hello World!'
def hello_world():
now = datetime.datetime.now()
timeString = now.strftime("%Y-%m-%d %H:%M")
templateData = {
'title' : 'HELLO!',
'time': timeString
}
return render_template('index.html', **templateData)
if __name__ == '__main__':
app.run()
pictures/pflanze.png

60.3 KiB

const btn2 = document.getElementById('btn2');
btn2.addEventListener('click', function handleClick() {
const initialText = 'Pumpe an';
if (btn2.textContent.toLowerCase().includes(initialText.toLowerCase())) {
btn2.textContent = 'Pumpe aus';
} else {
btn2.textContent = initialText;
}
});
\ No newline at end of file
body {
color: #CCFFCC;
background-color: #006633;
}
.button {
border: none;
color: #4D4B4B;
padding: 16px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
.button1:hover {
background-color: #4CAF50;
color: white;
}
.button2 {
background-color: #4D4B4B;
color: #CCFFCC;
border-radius: 10px;
}
.button2:hover {
background-color: #CCFFCC;
color: #4D4B4B;
}
.button1:active {
background-color: #258d28;
transform: translate(4px);
}
.button2:active {
background-color: #02688a;
transform: translate(4px);
}
.move-right{
margin-left: 50px;
}
/*th, td {
border: 1px solid black;
border-radius: 10px;
} */
table {
border: 1px solid black;
border-radius: 10px;
}
<!DOCTYPE html>
<head>
<meta charset=UTF-8>
<title>{{ title }}</title>
<link rel="stylesheet" href="../static/style.css/">
</head>
<body style="font-family: Helvetica;">
<h1 align="right"><font size="4">{{ time }}</font></h1>
<h2 align="center"><font size="8">Projektname</font></h2>
<img src="../pictures/pflanze.png">
<!--<button class="button button1">Green</button>-->
</br></br></br></br></br></br>
<!--später automatische Regulierung-->
<button id="btn2" class="button button2 move-right" style="margin-left: 200px;">Pumpe an</button>
<script src="../static/index.js"></script>
</br></br></br></br></br></br>
<!--Wertvergleich Licht-->
<table style="margin-left: 400px;background-color: rgb(77, 75, 75);">
<tr>
<!--Später ändern zu höher oder tiefer (nicht Ist/Soll-Wert)-->
<td><font size="6"><b>&nbsp;&nbsp;Ist-Wert&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |</b></font></td>
<td><font size="6"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Soll-Wert&nbsp;</b></font></td>
</tr>
<tr>
<td><font size="6">&nbsp;&nbsp;X&nbsp;PAR &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td><font size="6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;PAR&nbsp;</font></td>
</tr>
</table>
</br></br></br></br></br></br></br>
<!--WERTVERGLEICH PH-Wert-->
<table style="margin-left: 400px;background-color: rgb(77, 75, 75);">
<tr>
<!--Später ändern zu höher oder tiefer (nicht Ist/Soll-Wert)-->
<td><font size="6"><b>&nbsp;&nbsp;Ist-Wert&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|</b></font></td>
<td><font size="6"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Soll-Wert&nbsp; </b></font></td>
</tr>
<tr>
<td><font size="6">&nbsp;&nbsp;X &nbsp;pH &nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td><font size="6">&nbsp;&nbsp;&nbsp;&nbsp; X&nbsp; pH</font></td>
</tr>
</table>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Login page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="../static/style.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="container">
<h1>Please login</h1>
<br>
<form action="" method="post">
<input type="text" placeholder="Username" name="username" value="{{
request.form.username }}">
<input type="password" placeholder="Password" name="password" value="{{
request.form.password }}">
<input class="btn btn-default" type="submit" value="Login">
</form>
{% if error %}
<p class="error"><strong>Error:</strong> {{ error }}
{% endif %}
</div>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment