erster push
This commit is contained in:
commit
80e78d071e
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Modifizieren Sie das folgende Beispiel so,
|
||||||
|
# dass die Python-Dekorator-Syntax mit dem
|
||||||
|
# @-Zeichen verwendet wird!
|
||||||
|
|
||||||
|
def my_decorator(func):
|
||||||
|
def wrapper():
|
||||||
|
print("Before")
|
||||||
|
func()
|
||||||
|
print("After")
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
@my_decorator
|
||||||
|
def say_hello():
|
||||||
|
print("hello world!")
|
||||||
|
|
||||||
|
|
||||||
|
say_hello()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
def my_decorator_with_args(surrounding_text):
|
||||||
|
|
||||||
|
def actual_decorator(func):
|
||||||
|
def wrapper():
|
||||||
|
print(surrounding_text)
|
||||||
|
func()
|
||||||
|
print(surrounding_text)
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
return actual_decorator
|
||||||
|
|
||||||
|
### use it:
|
||||||
|
|
||||||
|
@my_decorator_with_args('***')
|
||||||
|
def say_hello():
|
||||||
|
print("Hello!")
|
||||||
|
|
||||||
|
say_hello()
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
from flask import Flask, render_template
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/', methods=['GET'])
|
||||||
|
def home():
|
||||||
|
return render_template('index.html')
|
||||||
|
|
||||||
|
app.run(host='0.0.0.0', port=5007)
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
body {
|
||||||
|
font-family: Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2 {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#abschnitt1 {
|
||||||
|
background-color: #e0f7fa; /* hellblau */
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#abschnitt2 {
|
||||||
|
background-color: #fff3e0; /* hellorange */
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.green {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
margin-top: 30px;
|
||||||
|
font-size: 0.8em;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Flask Info</title>
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flask</h1>
|
||||||
|
|
||||||
|
<div id="abschnitt1">
|
||||||
|
<h2>Flask Web development, one drop at a time</h2>
|
||||||
|
<p>
|
||||||
|
Welcome to Flask’s documentation. Get started with Installation and then get an overview with the Quickstart.
|
||||||
|
There is also a more detailed <strong>Tutorial</strong> that shows how to create a small but complete application with Flask.
|
||||||
|
Common patterns are described in the Patterns for Flask section.
|
||||||
|
The rest of the docs describe each component of Flask in detail, with a full reference in the API section.
|
||||||
|
Flask depends on the <span class="green">Jinja</span> template engine and the Werkzeug WSGI toolkit.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="abschnitt2">
|
||||||
|
<h2>User’s guide</h2>
|
||||||
|
<p>
|
||||||
|
Flask provides configuration and conventions, with <em>sensible defaults</em>, to get started.
|
||||||
|
This section of the documentation explains the different parts of the <strong><em>Flask framework</em></strong> and how they can be used, customized, and extended.
|
||||||
|
Beyond Flask itself, look for community-maintained extensions to add even more functionality.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Autor: Butenhoff – <a href="mailto:tobu6289@th-wildau.de">tobu6289@th-wildau.de</a>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
from flask import Flask, render_template
|
||||||
|
import mitarbeiter
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def startseite():
|
||||||
|
return render_template('index.html',
|
||||||
|
mycontent=mitarbeiter.GibAlleMitarbeiter(mitarbeiter.mitarbeiterliste))
|
||||||
|
|
||||||
|
@app.route('/mitarbeiter1')
|
||||||
|
def show1():
|
||||||
|
return render_template('index.html', mycontent=mitarbeiter.GibMitarbeiter(mitarbeiter.mitarbeiter1))
|
||||||
|
|
||||||
|
@app.route('/mitarbeiter2')
|
||||||
|
def show2():
|
||||||
|
return render_template('index.html', mycontent=mitarbeiter.GibMitarbeiter(mitarbeiter.mitarbeiter2))
|
||||||
|
|
||||||
|
@app.route('/mitarbeiter3')
|
||||||
|
def show3():
|
||||||
|
return render_template('index.html', mycontent=mitarbeiter.GibMitarbeiter(mitarbeiter.mitarbeiter3))
|
||||||
|
|
||||||
|
@app.route('/mitarbeiter')
|
||||||
|
def show_all():
|
||||||
|
return render_template('index.html', mycontent=mitarbeiter.GibAlleMitarbeiter(mitarbeiter.mitarbeiterliste))
|
||||||
|
|
||||||
|
app.run(host='0.0.0.0', port=5007)
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
#! /usr/bin/python3
|
||||||
|
|
||||||
|
mitarbeiter1 = ['Otto', 'Müller', 'Adlergestell 700', '12527 Berlin', '03067549000']
|
||||||
|
mitarbeiter2 = ['Hans', 'Lindner', 'Friedenstraße 4', '10464 Wildau', '03375 23925']
|
||||||
|
mitarbeiter3 = ['Eva', 'Habeck', 'Seestraße 5', '10430 Wildau', '03375 45321']
|
||||||
|
mitarbeiterliste= [mitarbeiter1, mitarbeiter2, mitarbeiter3]
|
||||||
|
|
||||||
|
for m in mitarbeiterliste:
|
||||||
|
print('Vorname: ' + m[0])
|
||||||
|
print('Nachname: ' + m[1])
|
||||||
|
print('Straße: ' + m[2])
|
||||||
|
print('PLZ Ort: ' + m[3])
|
||||||
|
print('Telefonnr.: ' + m[4])
|
||||||
|
print('-----------------------------')
|
||||||
|
|
||||||
|
def GibMitarbeiter(mitarbeiter):
|
||||||
|
string = f"<span id='vorname'>Vorname: {mitarbeiter[0]}</span><br>"
|
||||||
|
string += f"Nachname: {mitarbeiter[1]}<br>"
|
||||||
|
string += f"Straße: {mitarbeiter[2]}<br>"
|
||||||
|
string += f"Ort: {mitarbeiter[3]}<br>"
|
||||||
|
string += f"Telefon: {mitarbeiter[4]}<br><br>"
|
||||||
|
return string
|
||||||
|
|
||||||
|
def GibAlleMitarbeiter(liste):
|
||||||
|
text = ""
|
||||||
|
for m in liste:
|
||||||
|
text += GibMitarbeiter(m)
|
||||||
|
return text
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print(GibMitarbeiter(mitarbeiter1))
|
||||||
|
print(GibAlleMitarbeiter(mitarbeiterliste))
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Mitarbeiterliste</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Verdana, Arial, sans-serif;
|
||||||
|
font-size: 87.5%;
|
||||||
|
background-color: AliceBlue;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: Indigo;
|
||||||
|
}
|
||||||
|
#vorname {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
margin-top: 40px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Mitarbeiterliste</h1>
|
||||||
|
<p>{{ mycontent | safe }}</p>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Autor: Butenhoff – <a href="mailto: tobu6289@thwildau.de">tobu6289@th-wildau.de</a>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue