/
webapp.py
executable file
·59 lines (53 loc) · 1.7 KB
/
webapp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /usr/bin/python
from bottle import route, run, template
import random
import mfetcher
mfetcher.updateMangaDb()
@route('/')
def list():
mfetcher.updateMangaDb()
entries = random.sample(mfetcher.database["manga"],40)
templatePage = '''
<html>
<head>
</head>
<body style="font-size:24px;font-family: sans;">
% for manga in db:
<a href="{{manga["a"]}}">{{manga["t"]}}</a><br />
% end
<br />
<br />
Powered by <a href="http://mangaeden.com">mangaeden.com</a>
</body>
</html>
'''
return template(templatePage, db=entries)
@route('/<manga>')
@route('/<manga>/<chapter>')
@route('/<manga>/<chapter>/<page>')
def image(manga,chapter=1,page=0):
nextPage = int(page) + 1
nextChapter = int(chapter) + 1
nextPageUrl = '/'+manga+'/'+str(chapter)+'/'+str(nextPage)
nextChapterUrl = '/'+manga+'/'+str(nextChapter)+'/0'
imgUrl = mfetcher.get_page_url_from_coordinates(manga,chapter,page)
nextImgUrl = mfetcher.get_page_url_from_coordinates(manga,chapter,nextPage)
templatePage = '''
<html>
<head>
</head>
<body>
<a href="{{nextPageUrl}}">
<img style="width:100%" src="{{imgUrl}}" />
</a>
<br />
<br />
Powered by <a href="http://mangaeden.com">mangaeden.com</a>
</body>
</html>
'''
nextUrl = nextPageUrl
if nextImgUrl == None:
nextUrl = nextChapterUrl
return template(templatePage,nextPageUrl=nextUrl, imgUrl=imgUrl)
run(host='0.0.0.0', port=80)