From dbca1eb0ab6464d84b7447235a08326866aea878 Mon Sep 17 00:00:00 2001 From: jakobsn Date: Mon, 30 Sep 2019 15:32:27 +0200 Subject: [PATCH] readme --- README.md | 6 +++++- requirements.txt | 2 ++ static/sql/init.sql | 9 +++++++++ templates/index.html | 18 +++++++++++------- vulnapp.py | 14 ++++++++++++-- 5 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 static/sql/init.sql diff --git a/README.md b/README.md index a4442e7..4c7d3e2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ +Prerequisites + +Python >= 3.5 + INSTALL pip install -r requirements.txt RUN -gunicorn --workers=2 vulnapp +python vulnapp diff --git a/requirements.txt b/requirements.txt index 90cd3f6..4695e76 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ web.py==0.40 +mysql-connector==2.2.9 + diff --git a/static/sql/init.sql b/static/sql/init.sql new file mode 100644 index 0000000..8e5cbca --- /dev/null +++ b/static/sql/init.sql @@ -0,0 +1,9 @@ + +create database db; + +CREATE TABLE `db`.`users` ( + `userid` INT NOT NULL, + `username` VARCHAR(45) NULL, + `password` VARCHAR(45) NULL, + PRIMARY KEY (`userid`)); + diff --git a/templates/index.html b/templates/index.html index a6963d9..ef3b223 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,4 +1,4 @@ -$def with (name) +$def with (friends) Friends @@ -12,12 +12,16 @@ $def with (name)

Friends

Friends - - $if name: -

I just wanted to say hello to $name.

- $else: -

Hello, world!

-

Login, or become a Friend!

+

Login, or become a friend!

+ +

Regitered friends:

+ + + + diff --git a/vulnapp.py b/vulnapp.py index 2b67f86..ceb47fa 100644 --- a/vulnapp.py +++ b/vulnapp.py @@ -5,12 +5,22 @@ urls = ( '/', 'application' ) +db = web.database( + dbn="mysql", + host='127.0.0.1', + port=3306, + user='kalle', + pw='123p', + db='db' +) + class application(): def GET(self): name = 'Bob' - return render.index(name) - + friends = db.select('users') + return render.index(friends) + if __name__ == "__main__": app = web.application(urls, globals()) app.run()