Created
May 6, 2018 23:28
-
-
Save s-yoshiki/30de296d68ad7c3191e5674c6f84e6ef to your computer and use it in GitHub Desktop.
ディレクトリ内の画像を一覧表示
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
import os | |
images_path = "./src/" | |
def getHtmlHeader(): | |
return """ | |
<!DOCTYPE html> | |
<html> | |
<header> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script> | |
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous"> | |
</header> | |
<body> | |
<div class="container"> | |
""" | |
def getHtmlFooter(): | |
return """ | |
</div> | |
</body> | |
</html> | |
""" | |
def makeContent(images): | |
html = "" | |
for value in images: | |
html += "<h2>" + value + "</h2>" | |
html += "<img src='"+images_path + value + "' style='width:100%'>" | |
html += "<br><br>" | |
return html | |
if __name__ == '__main__': | |
directory = os.listdir('./src') | |
f = open('./test.html','w') | |
f.write(getHtmlHeader()) | |
f.write(makeContent(directory)) | |
f.write(getHtmlFooter()) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment