소스 검색

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

https
jakobsn 6 년 전
부모
커밋
1161b9da74
3개의 변경된 파일18개의 추가작업 그리고 6개의 파일을 삭제
  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 파일 보기

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

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


+ 12
- 2
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__":


+ 6
- 2
src/app/templates/index.html 파일 보기

@@ -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>

불러오는 중...
취소
저장