WebApp

Check-in [209eecc6f8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:viewlog access protected by decorator
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:209eecc6f806798ce6d61fdc4f37d5f692133fc3cef715cac0cb8df6a7c8f0ad
User & Date: sebpc 2018-05-26 15:54:59
Context
2018-05-27
16:25
Exceptions partially implemented check-in: d98be4905c user: sebpc tags: trunk
2018-05-26
15:54
viewlog access protected by decorator check-in: 209eecc6f8 user: sebpc tags: trunk
2018-05-25
18:28
Created checker decorator and a decorator template, checker implemented to simple_webapp check-in: 083431b7de user: sebpc tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to vsearch4web.py.

1
2
3

4
5


6
7










8
9
10
11
12
13
14
..
35
36
37
38
39
40
41

42
43
44
45
46
47
48
from flask import Flask, render_template, request, escape
from vsearch import search4letters
from DBcm import UseDatabase

app = Flask(__name__)



db = 'vsearchlog.db'











def log_request(req: 'flask_request', res: str) -> None:
    with UseDatabase(db) as cursor:
        _SQL = """insert into log
        (phrase, letters, ip, browser_string, results)
        values
        (?, ?, ?, ?, ?);"""

................................................................................

@app.route('/')
@app.route('/entry')
def entry_page() -> 'html':
	return render_template('entry.html', the_title='Welcome to search4letters on the web')

@app.route('/viewlog')

def view_the_log() -> str:
    with UseDatabase(db) as cursor:
        _SQL = """select phrase, letters, ip, browser_string, results
        from log;"""
        cursor.execute(_SQL)
        contents = cursor.fetchall()
    titles = ('Phraise', 'Letters', 'Remote addr', 'User_agent', 'Results')
|


>


>
>


>
>
>
>
>
>
>
>
>
>







 







>







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
..
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from flask import Flask, render_template, request, escape, session
from vsearch import search4letters
from DBcm import UseDatabase
from checker import check_logged_in
app = Flask(__name__)

app.secret_key = 'Moj$3kret'

db = 'vsearchlog.db'

@app.route('/login')
def login():
    session['logged_in'] = True
    return 'Jestes teraz zalogowany'

@app.route('/logout')
def logout():
    session.pop('logged_in')
    return 'Zostales wylogowany'

def log_request(req: 'flask_request', res: str) -> None:
    with UseDatabase(db) as cursor:
        _SQL = """insert into log
        (phrase, letters, ip, browser_string, results)
        values
        (?, ?, ?, ?, ?);"""

................................................................................

@app.route('/')
@app.route('/entry')
def entry_page() -> 'html':
	return render_template('entry.html', the_title='Welcome to search4letters on the web')

@app.route('/viewlog')
@check_logged_in
def view_the_log() -> str:
    with UseDatabase(db) as cursor:
        _SQL = """select phrase, letters, ip, browser_string, results
        from log;"""
        cursor.execute(_SQL)
        contents = cursor.fetchall()
    titles = ('Phraise', 'Letters', 'Remote addr', 'User_agent', 'Results')