Update setup.py
[PyMotherless.git] / pymotherless-httpd.py
blob748526fb86e0bab2a24a4a2219ba9cb46758e143
1 #!/usr/bin/env python
3 '''
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Revised BSD License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 Revised BSD License for more details.
12 Copyright 2011-2015 Game Maker 2k - https://github.com/GameMaker2k
13 Copyright 2011-2015 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
15 $FileInfo: httpd.py - Last Update: 1/30/2019 Ver. 0.4.7 RC 4 - Author: cooldude2k $
16 '''
18 import tempfile, uuid, re, os, sys, cherrypy, pymotherless, argparse, time, datetime;
19 if(sys.version[0]=="2"):
20 try:
21 from cStringIO import StringIO;
22 except ImportError:
23 from StringIO import StringIO;
24 # From http://python-future.org/compatible_idioms.html
25 from urlparse import urlparse, urlunparse, urlsplit, urlunsplit, urljoin;
26 from urllib import urlencode;
27 from urllib2 import urlopen, Request, HTTPError;
28 import urllib2, urlparse, cookielib;
29 if(sys.version[0]>="3"):
30 from io import StringIO, BytesIO;
31 # From http://python-future.org/compatible_idioms.html
32 from urllib.parse import urlparse, urlunparse, urlsplit, urlunsplit, urljoin, urlencode;
33 from urllib.request import urlopen, Request;
34 from urllib.error import HTTPError;
35 import urllib.request as urllib2;
36 import urllib.parse as urlparse;
37 import http.cookiejar as cookielib;
38 import logging as log;
40 __project__ = pymotherless.__project__;
41 __program_name__ = pymotherless.__program_name__;
42 __project_url__ = pymotherless.__project_url__;
43 __version_info__ = pymotherless.__version_info__;
44 __version_date_info__ = pymotherless.__version_date_info__;
45 __version_date__ = pymotherless.__version_date__;
46 __version_date_plusrc__ = pymotherless.__version_date_plusrc__
47 __version__ = pymotherless.__version__;
48 __version_date_plusrc__ = pymotherless.__version_date_plusrc__;
50 geturls_cj = pymotherless.geturls_cj;
51 geturls_ua = pymotherless.geturls_ua;
52 geturls_ua_firefox_windows7 = pymotherless.geturls_ua_firefox_windows7;
53 geturls_ua_seamonkey_windows7 = pymotherless.geturls_ua_seamonkey_windows7;
54 geturls_ua_chrome_windows7 = pymotherless.geturls_ua_chrome_windows7;
55 geturls_ua_chromium_windows7 = pymotherless.geturls_ua_chromium_windows7;
56 geturls_ua_palemoon_windows7 = pymotherless.geturls_ua_palemoon_windows7;
57 geturls_ua_opera_windows7 = pymotherless.geturls_ua_opera_windows7;
58 geturls_ua_vivaldi_windows7 = pymotherless.geturls_ua_chromium_windows7;
59 geturls_ua_internet_explorer_windows7 = pymotherless.geturls_ua_internet_explorer_windows7;
60 geturls_ua_microsoft_edge_windows7 = pymotherless.geturls_ua_microsoft_edge_windows7;
61 geturls_ua_pymotherless_python = pymotherless.geturls_ua_pymotherless_python;
62 geturls_ua_pymotherless_python_alt = pymotherless.geturls_ua_pymotherless_python_alt;
63 geturls_ua_googlebot_google = pymotherless.geturls_ua_googlebot_google;
64 geturls_ua_googlebot_google_old = pymotherless.geturls_ua_googlebot_google_old;
65 geturls_headers = pymotherless.geturls_headers;
66 geturls_headers_firefox_windows7 = pymotherless.geturls_headers_firefox_windows7;
67 geturls_headers_seamonkey_windows7 = pymotherless.geturls_headers_seamonkey_windows7;
68 geturls_headers_chrome_windows7 = pymotherless.geturls_headers_chrome_windows7;
69 geturls_headers_chromium_windows7 = pymotherless.geturls_headers_chromium_windows7;
70 geturls_headers_palemoon_windows7 = pymotherless.geturls_headers_palemoon_windows7;
71 geturls_headers_opera_windows7 = pymotherless.geturls_headers_opera_windows7;
72 geturls_headers_vivaldi_windows7 = pymotherless.geturls_headers_vivaldi_windows7;
73 geturls_headers_internet_explorer_windows7 = pymotherless.geturls_headers_internet_explorer_windows7;
74 geturls_headers_microsoft_edge_windows7 = pymotherless.geturls_headers_microsoft_edge_windows7;
75 geturls_headers_pymotherless_python = pymotherless.geturls_headers_pymotherless_python;
76 geturls_headers_pymotherless_python_alt = pymotherless.geturls_headers_pymotherless_python_alt;
77 geturls_headers_googlebot_google = pymotherless.geturls_headers_googlebot_google;
78 geturls_headers_googlebot_google_old = pymotherless.geturls_headers_googlebot_google_old;
79 geturls_download_sleep = pymotherless.geturls_download_sleep;
81 parser = argparse.ArgumentParser(description="A web server that draws barcodes with PyUPC-EAN powered by CherryPy web server.");
82 parser.add_argument("--port", "--port-number", default=8080, help="port number to use for server.");
83 parser.add_argument("--host", "--host-name", default="127.0.0.1", help="host name to use for server.");
84 parser.add_argument("--verbose", "--verbose-mode", help="show log on terminal screen.", action="store_true");
85 parser.add_argument("--gzip", "--gzip-mode", help="enable gzip http requests.", action="store_true");
86 parser.add_argument("--gzipfilter", "--gzipfilter-mode", help="enable gzipfilter mode.", action="store_true");
87 parser.add_argument("--accesslog", "--accesslog-file", help="location to store access log file.");
88 parser.add_argument("--errorlog", "--errorlog-file", help="location to store error log file.");
89 parser.add_argument("--timeout", "--response-timeout", default=6000, help="the number of seconds to allow responses to run.");
90 parser.add_argument("--environment", "--server-environment", default="production", help="The server.environment entry controls how CherryPy should run.");
91 getargs = parser.parse_args();
92 if(getargs.verbose==True):
93 log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG);
94 if(getargs.port is not None):
95 port = int(getargs.port);
96 else:
97 port = 8080;
98 if(getargs.host is not None):
99 host = str(getargs.host);
100 else:
101 host = "127.0.0.1";
102 if(getargs.timeout is not None):
103 timeout = int(getargs.timeout);
104 else:
105 timeout = 6000;
106 if(getargs.accesslog is not None):
107 accesslog = str(getargs.accesslog);
108 else:
109 accesslog = "./access.log";
110 if(getargs.errorlog is not None):
111 errorlog = str(getargs.errorlog);
112 else:
113 errorlog = "./errors.log";
114 if(getargs.environment is not None):
115 serv_environ = str(getargs.environment);
116 else:
117 serv_environ = "production";
118 pro_app_name = "Barcode Generator 2k";
119 pro_app_subname = "(PyUPC-EAN)";
120 pro_app_version = pymotherless.__version__;
121 radsta=0;
122 radmax=360;
123 radinc=5;
124 radout="\n";
125 while(radsta<=radmax):
126 if(radsta==0):
127 radout += "<option value=\""+str(radsta)+"\" selected=\"selected\">"+str(radsta)+" &#176;</option>\n";
128 if(radsta>0):
129 radout += "<option value=\""+str(radsta)+"\">"+str(radsta)+" &#176;</option>\n";
130 radsta = radsta + radinc;
131 ServerSignature = "<address><a href=\"https://github.com/GameMaker2k/PyUPC-EAN\" title=\"PyUPC-EAN barcode generator\">PyUPC-EAN</a>/%s (<a href=\"http://www.cherrypy.org/\" title=\"CherryPy python web server\">CherryPy</a>/%s)</address>" % (pymotherless.__version__, cherrypy.__version__);
132 IndexHTMLCode = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n<head>\n<title> "+pro_app_name+" "+pro_app_subname+" </title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n<meta http-equiv=\"Content-Language\" content=\"en\" />\n<meta name=\"generator\" content=\"CherryPy\" />\n<meta name=\"author\" content=\"Game Maker 2k\" />\n<meta name=\"keywords\" content=\"barcode,upc,ean,stf,itf,itf14,upca,upce,ean2,ean5,ean8,ean13,code11,code39,code93,codabar,msi\" />\n<meta name=\"description\" content=\"Barcode Generator with PyUPC-EAN\" /><meta name=\"resource-type\" content=\"document\" />\n<meta name=\"distribution\" content=\"global\" />\n<link rel=\"Generator\" href=\"http://www.cherrypy.org/\" title=\"CherryPy\" />\n</head>\n<body>\n<form name=\"pymotherless\" id=\"pymotherless\" method=\"get\" action=\"/pymotherless/\" onsubmit=\"location.href='/generate/'+pymotherless.bctype.value+'/'+pymotherless.size.value+'/'+pymotherless.rotate.value+'/'+pymotherless.upc.value+'.'+pymotherless.imgtype.value; return false;\">\n<fieldset>\n<legend>Barcode Info: </legend>\n<label style=\"cursor: pointer;\" for=\"upc\">Enter UPC/EAN: </label><br />\n<input type=\"text\" id=\"upc\" name=\"upc\" /><br />\n<label style=\"cursor: pointer;\" for=\"imgtype\">Select a image type: </label><br />\n<select id=\"imgtype\" name=\"imgtype\">\n<option value=\"png\" selected=\"selected\">PNG Image</option>\n<option value=\"gif\">GIF Image</option>\n<option value=\"jpeg\">JPEG Image</option>\n<option value=\"bmp\">BMP Image</option>\n<option value=\"tiff\">TIFF Image</option>\n</select><br />\n<label style=\"cursor: pointer;\" for=\"size\">Select barcode size: </label><br />\n<select id=\"size\" name=\"size\">\n<option value=\"1\" selected=\"selected\">1x</option>\n<option value=\"2\">2x</option>\n<option value=\"3\">3x</option>\n<option value=\"4\">4x</option>\n<option value=\"5\">5x</option>\n<option value=\"6\">6x</option>\n<option value=\"7\">7x</option>\n<option value=\"8\">8x</option>\n<option value=\"9\">9x</option>\n<option value=\"10\">10x</option>\n</select><br />\n<label style=\"cursor: pointer;\" for=\"bctype\">Select barcode type: </label><br />\n<select id=\"bctype\" name=\"bctype\">\n<option value=\"upca\" selected=\"selected\">UPC-A</option>\n<option value=\"upce\">UPC-E</option>\n<option value=\"ean13\">EAN-13</option>\n<option value=\"ean8\">EAN-8</option>\n<option value=\"ean2\">EAN-2</option>\n<option value=\"ean5\">EAN-5</option>\n<option value=\"stf\">STF</option>\n<option value=\"itf\">ITF</option>\n<option value=\"itf14\">ITF-14</option>\n<option value=\"code11\">Code 11</option>\n<option value=\"code39\">Code 39</option>\n<option value=\"code93\">Code 93</option>\n<option value=\"codabar\">Codabar</option>\n<option value=\"msi\">MSI</option>\n</select><br />\n<label style=\"cursor: pointer;\" for=\"rotate\">Select degrees to rotate image by: </label><br />\n<select id=\"rotate\" name=\"rotate\">"+radout+"</select><br />\n<input type=\"submit\" value=\"Generate\" />\n</fieldset>\n</form><br />\n"+ServerSignature+"\n</body>\n</html>";
133 class GenerateIndexPage(object):
134 @cherrypy.expose
135 def default(self, *args, **kwargs):
136 cherrypy.response.headers['Content-Type'] = 'text/html; charset=UTF-8';
137 getpyurlpath = urlparse.urlparse(cherrypy.url()).path;
138 getpymotherless = "http://motherless.com"+getpyurlpath;
139 pymotherlessinfo = pymotherless.get_motherless_link_type_alt(getpymotherless);
140 IndexHTMLCode = getpyurlpath+" - "+pymotherlessinfo['motherlessinfo'];
141 if(pymotherlessinfo['motherlessinfo']=="sample" or pymotherlessinfo['motherlessinfo']=="sample-videos"):
142 IndexHTMLCode = "";
143 getpyurlinfo = pymotherless.get_motherless_sample_links(geturls_headers, geturls_cj, numoflinks=15, urltype="video");
144 counti = 0;
145 while(counti<15):
146 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['videos']['recent'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['videos']['recent'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['videos']['recent'][counti]['title']+"\" title=\""+getpyurlinfo['videos']['recent'][counti]['title']+"\" /></a>\n";
147 counti = counti + 1;
148 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
149 counti = 0;
150 while(counti<15):
151 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['videos']['favorited'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['videos']['favorited'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['videos']['favorited'][counti]['title']+"\" title=\""+getpyurlinfo['videos']['favorited'][counti]['title']+"\" /></a>\n";
152 counti = counti + 1;
153 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
154 counti = 0;
155 while(counti<15):
156 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['videos']['viewed'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['videos']['viewed'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['videos']['viewed'][counti]['title']+"\" title=\""+getpyurlinfo['videos']['viewed'][counti]['title']+"\" /></a>\n";
157 counti = counti + 1;
158 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
159 counti = 0;
160 while(counti<15):
161 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['videos']['commented'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['videos']['commented'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['videos']['commented'][counti]['title']+"\" title=\""+getpyurlinfo['videos']['commented'][counti]['title']+"\" /></a>\n";
162 counti = counti + 1;
163 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
164 counti = 0;
165 while(counti<15):
166 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['videos']['popular'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['videos']['popular'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['videos']['popular'][counti]['title']+"\" title=\""+getpyurlinfo['videos']['popular'][counti]['title']+"\" /></a>\n";
167 counti = counti + 1;
168 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
169 counti = 0;
170 while(counti<15):
171 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['videos']['live'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['videos']['live'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['videos']['live'][counti]['title']+"\" title=\""+getpyurlinfo['videos']['live'][counti]['title']+"\" /></a>\n";
172 counti = counti + 1;
173 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
174 counti = 0;
175 while(counti<15):
176 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['videos']['random'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['videos']['random'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['videos']['random'][counti]['title']+"\" title=\""+getpyurlinfo['videos']['random'][counti]['title']+"\" /></a>\n";
177 counti = counti + 1;
178 if(pymotherlessinfo['motherlessinfo']=="sample-images"):
179 IndexHTMLCode = "";
180 getpyurlinfo = pymotherless.get_motherless_sample_links(geturls_headers, geturls_cj, numoflinks=15, urltype="image");
181 counti = 0;
182 while(counti<15):
183 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['images']['recent'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['images']['recent'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['images']['recent'][counti]['title']+"\" title=\""+getpyurlinfo['images']['recent'][counti]['title']+"\" /></a>\n";
184 counti = counti + 1;
185 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
186 counti = 0;
187 while(counti<15):
188 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['images']['favorited'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['images']['favorited'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['images']['favorited'][counti]['title']+"\" title=\""+getpyurlinfo['images']['favorited'][counti]['title']+"\" /></a>\n";
189 counti = counti + 1;
190 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
191 counti = 0;
192 while(counti<15):
193 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['images']['viewed'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['images']['viewed'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['images']['viewed'][counti]['title']+"\" title=\""+getpyurlinfo['images']['viewed'][counti]['title']+"\" /></a>\n";
194 counti = counti + 1;
195 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
196 counti = 0;
197 while(counti<15):
198 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['images']['commented'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['images']['commented'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['images']['commented'][counti]['title']+"\" title=\""+getpyurlinfo['images']['commented'][counti]['title']+"\" /></a>\n";
199 counti = counti + 1;
200 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
201 counti = 0;
202 while(counti<15):
203 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['images']['popular'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['images']['popular'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['images']['popular'][counti]['title']+"\" title=\""+getpyurlinfo['images']['popular'][counti]['title']+"\" /></a>\n";
204 counti = counti + 1;
205 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
206 counti = 0;
207 while(counti<15):
208 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['images']['live'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['images']['live'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['images']['live'][counti]['title']+"\" title=\""+getpyurlinfo['images']['live'][counti]['title']+"\" /></a>\n";
209 counti = counti + 1;
210 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
211 counti = 0;
212 while(counti<15):
213 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo['images']['random'][counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo['images']['random'][counti]['thumbnail']+"\" alt=\""+getpyurlinfo['images']['random'][counti]['title']+"\" title=\""+getpyurlinfo['images']['random'][counti]['title']+"\" /></a>\n";
214 counti = counti + 1;
215 if(pymotherlessinfo['motherlessinfo']=="gallery"):
216 IndexHTMLCode = "";
217 try:
218 getpage=int(cherrypy.request.params.get('page', None));
219 except TypeError:
220 getpage=1;
221 except ValueError:
222 getpage=1;
223 getpyurlinfo = pymotherless.get_motherless_galleries_links(getpymotherless, geturls_headers, geturls_cj, page=getpage);
224 counti = 0;
225 maxi = getpyurlinfo['numoflinks'];
226 while(counti<maxi):
227 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo[counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo[counti]['thumbnail']+"\" alt=\""+getpyurlinfo[counti]['title']+"\" title=\""+getpyurlinfo[counti]['title']+"\" /></a>\n";
228 counti = counti + 1;
229 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
230 counti = 1;
231 maxi = getpyurlinfo['pages'];
232 print(str(maxi));
233 while(counti<maxi):
234 IndexHTMLCode = IndexHTMLCode+" <a href=\"?page="+str(counti)+"\">"+str(counti)+"</a>\n";
235 counti = counti + 1;
236 if(pymotherlessinfo['motherlessinfo']=="group"):
237 IndexHTMLCode = "";
238 try:
239 getpage=int(cherrypy.request.params.get('page', None));
240 except TypeError:
241 getpage=1;
242 except ValueError:
243 getpage=1;
244 getpyurlinfo = pymotherless.get_motherless_groups(getpymotherless, geturls_headers, geturls_cj, page=getpage);
245 counti = 0;
246 maxi = getpyurlinfo['numoflinks'];
247 while(counti<maxi):
248 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo[counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo[counti]['thumbnail']+"\" alt=\""+getpyurlinfo[counti]['title']+"\" title=\""+getpyurlinfo[counti]['title']+"\" /></a>\n";
249 counti = counti + 1;
250 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
251 counti = 1;
252 maxi = getpyurlinfo['pages'];
253 print(str(maxi));
254 while(counti<maxi):
255 IndexHTMLCode = IndexHTMLCode+" <a href=\"?page="+str(counti)+"\">"+str(counti)+"</a>\n";
256 counti = counti + 1;
257 if(pymotherlessinfo['motherlessinfo']=="member"):
258 IndexHTMLCode = "";
259 try:
260 getpage=int(cherrypy.request.params.get('page', None));
261 except TypeError:
262 getpage=1;
263 except ValueError:
264 getpage=1;
265 getpyurlinfo = pymotherless.get_motherless_search_members(getpymotherless, geturls_headers, geturls_cj, page=getpage);
266 counti = 0;
267 maxi = getpyurlinfo['numoflinks'];
268 while(counti<maxi):
269 IndexHTMLCode = IndexHTMLCode+" <a href=\""+getpyurlinfo[counti]['url'].replace('http://motherless.com', '')+"\"><img src=\""+getpyurlinfo[counti]['avatarurl']+"\" alt=\""+getpyurlinfo[counti]['username']+"\" title=\""+getpyurlinfo[counti]['username']+"\" /></a>\n";
270 counti = counti + 1;
271 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
272 counti = 1;
273 maxi = getpyurlinfo['pages'];
274 print(str(maxi));
275 while(counti<maxi):
276 IndexHTMLCode = IndexHTMLCode+" <a href=\"?page="+str(counti)+"\">"+str(counti)+"</a>\n";
277 counti = counti + 1;
278 if(pymotherlessinfo['motherlessinfo']=="link"):
279 IndexHTMLCode = "";
280 getpyurlinfo = pymotherless.get_motherless_links(getpymotherless, geturls_headers, geturls_cj);
281 if(getpyurlinfo['type']=="images"):
282 IndexHTMLCode = "<img src=\""+getpyurlinfo['url']+"\" alt=\""+getpyurlinfo['title']+"\" title=\""+getpyurlinfo['title']+"\" style=\"width: "+str(getpyurlinfo['width'])+"px; height: "+str(getpyurlinfo['height'])+"px;\" />";
283 if(getpyurlinfo['type']=="videos"):
284 IndexHTMLCode = "<video width=\"632\" height=\"432\" controls><source src=\""+getpyurlinfo['url']+"\" type=\"video/mp4\">Your browser does not support the video tag.</video>";
285 IndexHTMLCode = IndexHTMLCode+"<div><br />&nbsp;<br /></div>\n";
286 getpyurlcomet = pymotherless.get_motherless_links_comments(getpymotherless, geturls_headers, geturls_cj);
287 counti = 0;
288 maxi = getpyurlcomet['numofallposts'];
289 while(counti<maxi):
290 IndexHTMLCode = IndexHTMLCode+"<fieldset><legend>"+getpyurlcomet[counti]['username']+"</legend><img src=\""+getpyurlcomet[counti]['avatarurl']+"\" alt=\""+getpyurlcomet[counti]['username']+"\" title=\""+getpyurlcomet[counti]['username']+"\" /><br />"+getpyurlcomet[counti]['post']+"</fieldset>";
291 counti = counti + 1;
292 return IndexHTMLCode;
293 default.exposed = True;
295 cherrypy.config.update({"environment": serv_environ,
296 "log.error_file": errorlog,
297 "log.access_file": accesslog,
298 "log.screen": getargs.verbose,
299 "gzipfilter.on": getargs.gzipfilter,
300 "tools.gzip.on": getargs.gzip,
301 "tools.gzip.mime_types": ['text/*'],
302 "server.socket_host": host,
303 "server.socket_port": port,
304 "response.timeout": timeout,
306 cherrypy.quickstart(GenerateIndexPage());