Przeglądaj źródła

database connected used networking in docker specify ip and network to launch

https
jakobsn 6 lat temu
rodzic
commit
1161b9da74
3 zmienionych plików z 18 dodań i 6 usunięć
  1. +0
    -2
      docker-compose.yml
  2. +12
    -2
      src/app/main.py
  3. +6
    -2
      src/app/templates/index.html

+ 0
- 2
docker-compose.yml Wyświetl plik

@@ -3,8 +3,6 @@ services:

db:
ports:
- "3306:3306"
build:
context: ./mysql
dockerfile: Dockerfile


+ 12
- 2
src/app/main.py Wyświetl plik

@@ -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__":


+ 6
- 2
src/app/templates/index.html Wyświetl plik

@@ -1,4 +1,4 @@
$def with (login_form)
$def with (login_form, friends)

<head>
<title>Friends</title>
@@ -19,6 +19,10 @@ $def with (login_form)
$:login_form.render()
</form>

<h3>Registered friends:</h3>
<ul>
$for name in friends:
<li id="t$name.userid">$name.username</li>
</ul>

</body>

Ładowanie…
Anuluj
Zapisz