From 1161b9da74d7541b164bb2db1acfbc64ca1a4348 Mon Sep 17 00:00:00 2001 From: jakobsn Date: Thu, 3 Oct 2019 13:54:33 +0200 Subject: [PATCH] database connected used networking in docker specify ip and network to launch --- docker-compose.yml | 2 -- src/app/main.py | 14 ++++++++++++-- src/app/templates/index.html | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 31c98fb..cbc4909 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,6 @@ services: db: - ports: - - "3306:3306" build: context: ./mysql dockerfile: Dockerfile diff --git a/src/app/main.py b/src/app/main.py index 636355e..ef0472c 100644 --- a/src/app/main.py +++ b/src/app/main.py @@ -6,6 +6,16 @@ urls = ( '/', 'index' ) +# Connect to database +db = web.database( + dbn="mysql", + host='172.18.0.22', + port=3306, + user='root', + pw='root', + db='db' +) + # Initialize application using the web py framework app = web.application(urls, globals()) @@ -22,8 +32,8 @@ class index(): def GET(self): - #friends = db.select('users') - return render.index(login_form) + friends = db.select('users') + return render.index(login_form, friends) if __name__ == "__main__": diff --git a/src/app/templates/index.html b/src/app/templates/index.html index bd2742a..6604d0b 100644 --- a/src/app/templates/index.html +++ b/src/app/templates/index.html @@ -1,4 +1,4 @@ -$def with (login_form) +$def with (login_form, friends) Friends @@ -19,6 +19,10 @@ $def with (login_form) $:login_form.render() - +

Registered friends:

+ \ No newline at end of file