Skip to content

Commit 1562177

Browse files
committed
Fix to generate static file automatically.
1 parent f61a636 commit 1562177

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
# Simple Image File Viewer
22

33
## ABOUT
4-
This system supports image files viewer.
5-
You can manage and share your image files easily and security.
4+
5+
This system supports simple image files viewer.
6+
You can manage and share your image files easily.
67

78
## USAGE
89

910
### ENVIRONMENT
1011

1112
* Python3.6
1213

13-
### INSTALL
14+
### INSTALL
1415

1516
```bash
1617
git clone https://github.com/pyohei/image-viewer.git
1718
cd image-viewer
19+
```
20+
21+
If you want to activate virtualenv, type the below sentence.
1822

19-
# if you want to prepare virtualenv, input the below word
23+
```bash
2024
python -m venv venv
2125
source venv/bin/activate
2226
```
2327

28+
### SETUP
29+
30+
After install, you must import python library.
31+
32+
```bash
33+
pip install -r requirements.txt
34+
```
35+
2436
### PREPARE
2537

2638
Before executing, you prepare
@@ -32,4 +44,5 @@ python main.py
3244
```
3345

3446
## LICENSE
47+
3548
* [MIT](https://github.com/pyohei/image-viewer/master/LICENSE)

images.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
<h1>よんくま一覧</h1>
3333
<div id="kumalinks" class="kumaimages example thumbs">
3434
% for i in images:
35-
<a href="/static/images/${i}">
36-
<img src="/static/images/${i}" width="8.5%" height="16%" />
35+
<a href="${i}">
36+
<img src="${i}" width="8.5%" height="16%" />
3737
</a>
3838
% endfor
3939
</div>

main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,21 @@ def _disp_images(request):
3535
username = params['username']
3636
userpass = params['userpass']
3737
is_login = __can_login(username, userpass)
38+
print('hoge')
3839
if 'sid' in request.cookies:
3940
sid = request.cookies['sid']
4041
is_login = __has_valid_cookie(sid)
42+
print('hogew')
4143
if not is_login:
4244
return _disp_login(request, u'Failur in login!!!')
4345
image_paths = []
46+
for r, d, fs in os.walk(PUBLIC_DIR):
47+
for f in fs:
48+
_p = os.path.join(r, f)
49+
50+
print(_p)
51+
print(os.path.join('static', _p.lstrip(PUBLIC_DIR)))
52+
image_paths.append(os.path.join('static', _p.lstrip(PUBLIC_DIR)))
4453
params = {}
4554
params['images'] = image_paths
4655
response = render_to_response(
@@ -71,7 +80,8 @@ def __add_routes(config):
7180
config.add_view(_disp_images, route_name='images')
7281
config.add_route('logout', '/logout')
7382
config.add_view(_logout, route_name='logout')
74-
config.add_static_view('static', 'static')
83+
config.add_static_view('static', PUBLIC_DIR)
84+
#config.add_static_view('static', 'static')
7585

7686

7787
def execute():
@@ -94,6 +104,7 @@ def execute():
94104
p.add_argument('public_dir', help=p_h)
95105
args = p.parse_args()
96106
PUBLIC_DIR = os.path.abspath(args.public_dir)
107+
print(PUBLIC_DIR)
97108
if not os.path.isdir(PUBLIC_DIR):
98109
print('public_dir doesn\'t exist!')
99110
quit()

0 commit comments

Comments
 (0)