flask_server.py 834 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python3
from flask import Flask, render_template
import sqlite3

DATABASE = "test.db"
app = Flask(__name__)
name = str(app.route)

def all_user():
    connection = sqlite3.connect("test.db")
    cursor = connection.cursor()       
    connection.row_factory = sqlite3.Row
    cursor.execute("SELECT username FROM benutzer")
    usernames = cursor.fetchall()
    return usernames

def one_user(name):
    connection = sqlite3.connect("test.db")
    cursor = connection.cursor()
    connection.row_factory = sqlite3.Row       
    cursor.execute("SELECT * FROM benutzer WHERE vname = " + str(name))
    username = cursor.fetchone()
    return username

@app.route('/user')
def aufruf():
    return render_template("user.html", user_nms = all_user())

if __name__ == '__main__':    
    app.run(host = "0.0.0.0", debug = True)