author | Tero Marttila <terom@fixme.fi> |
Tue, 05 May 2009 22:13:49 +0300 | |
changeset 19 | 0187eddad3eb |
parent 18 | 17e1136cc257 |
child 20 | 3feaac71738a |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/python2.5 |
18 | 2 |
# Copyright 2009 Tero Marttila |
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify |
|
5 |
# it under the terms of the GNU General Public License as published by |
|
6 |
# the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
# |
|
17 |
||
3 | 18 |
import werkzeug |
19 |
from werkzeug.exceptions import HTTPException |
|
0 | 20 |
|
1
71c7382994c4
rename logo.py -> index.cgi, and implement blurring
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
21 |
from PIL import Image, ImageDraw, ImageFont, ImageEnhance |
0 | 22 |
from cStringIO import StringIO |
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
23 |
import random, itertools, time, os.path |
0 | 24 |
|
5
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
25 |
if not hasattr(itertools, 'izip_longest') : |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
26 |
|
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
27 |
def izip_longest(*args, **kwds): |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
28 |
# izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
29 |
fillvalue = kwds.get('fillvalue') |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
30 |
def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
31 |
yield counter() # yields the fillvalue, or raises IndexError |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
32 |
fillers = itertools.repeat(fillvalue) |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
33 |
iters = [itertools.chain(it, sentinel(), fillers) for it in args] |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
34 |
try: |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
35 |
for tup in itertools.izip(*iters): |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
36 |
yield tup |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
37 |
except IndexError: |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
38 |
pass |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
39 |
|
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
40 |
itertools.izip_longest = izip_longest |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
41 |
|
3 | 42 |
class Defaults : |
43 |
# settings |
|
8 | 44 |
|
45 |
text_lang = 'en' |
|
0 | 46 |
|
7 | 47 |
chars = [ u'"', u'!', u'?' ] |
0 | 48 |
|
8 | 49 |
colors = [ |
3 | 50 |
"#0469af", |
51 |
"#fbc614", |
|
52 |
"#e1313b", |
|
53 |
] |
|
54 |
||
55 |
font_name = 'helvetica' |
|
56 |
font_size = 30 |
|
57 |
||
8 | 58 |
bg_color = "#ffffff" |
3 | 59 |
line_spacing = -10 |
60 |
sharpness = 0.6 |
|
0 | 61 |
|
7 | 62 |
img_format = 'png' |
63 |
||
8 | 64 |
TEXT_BY_LANG = dict( |
65 |
en = [ |
|
66 |
u"aalto", |
|
67 |
u"unive", |
|
68 |
u"rsity" |
|
69 |
], |
|
70 |
fi = [ |
|
71 |
u"aalto", |
|
72 |
u"yliop", |
|
73 |
u"isto" |
|
74 |
], |
|
75 |
se = [ |
|
76 |
u"aalto", |
|
77 |
u"univer", |
|
78 |
u"sitetet", |
|
79 |
], |
|
80 |
) |
|
81 |
||
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
82 |
STATIC_PATH = "static" |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
83 |
|
8 | 84 |
FONTS = { |
3 | 85 |
'dejavu-sans-bold': "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf", |
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
86 |
'helvetica': "fonts/HELR65W.TTF", |
3 | 87 |
} |
0 | 88 |
|
8 | 89 |
IMAGE_FORMATS = { |
90 |
'jpeg': 'jpeg', |
|
91 |
'png': 'png', |
|
92 |
'bmp': 'bmp' |
|
93 |
} |
|
94 |
||
6 | 95 |
FONT_SIZE_MAX = 1024 |
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
96 |
IMG_SIZE_MAX = 1024 |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
97 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
98 |
TILE_SIZE = (100, 100) |
3 | 99 |
|
18 | 100 |
SITE_URL = "http://qmsk.net/stuff/aaltologo/" |
101 |
SOURCE_URL = "http://hg.qmsk.net/aaltologotin" |
|
102 |
||
3 | 103 |
# enable debugging |
6 | 104 |
DEBUG = True |
105 |
||
0 | 106 |
|
107 |
def randomize (seq) : |
|
108 |
""" |
|
109 |
Returns the given sequence in random order as a list |
|
110 |
""" |
|
111 |
||
112 |
# copy |
|
113 |
l = list(seq) |
|
114 |
||
115 |
# rearrange |
|
116 |
random.shuffle(l) |
|
117 |
||
118 |
return l |
|
119 |
||
11 | 120 |
def randomize_str_char (str) : |
121 |
""" |
|
122 |
Randomize the given string by moving one char around |
|
123 |
""" |
|
124 |
||
125 |
l = list(str) |
|
126 |
||
127 |
c = l.pop(random.randint(0, len(l) - 1)) |
|
128 |
l.insert(random.randint(0, len(l)), c) |
|
129 |
||
130 |
return ''.join(l) |
|
131 |
||
132 |
def build_data (text, chars, line_colors, random_chars=True, random_text=False, random_text_char=False) : |
|
0 | 133 |
""" |
134 |
Returns a matrix of (text, color) tuples representing the data to render |
|
135 |
||
136 |
[ [ (str, str) ] ] |
|
137 |
||
138 |
text - list of lines |
|
139 |
chars - list of random chars to interpse |
|
140 |
line_colors - list of colors to draw the chars in |
|
11 | 141 |
random_chars - randomize the lines the chars go in |
142 |
random_text - randomize the chars in each line |
|
143 |
random_text_char - randomize each line by moving one char around |
|
0 | 144 |
""" |
145 |
||
146 |
data = [] |
|
16 | 147 |
|
148 |
# if no chars given, don't insert any |
|
149 |
if not chars : |
|
150 |
chars = [] |
|
151 |
||
152 |
# randomize char order across lines? |
|
9 | 153 |
if random_chars : |
154 |
chars = randomize(chars) |
|
0 | 155 |
|
5
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
156 |
for line, char, color in itertools.izip_longest(text, chars, line_colors, fillvalue=None) : |
15 | 157 |
if not line : |
158 |
continue |
|
159 |
||
0 | 160 |
# pick position to place char |
16 | 161 |
if len(line) >= 2 : |
162 |
pos = random.randint(1, len(line) - 1) |
|
163 |
else : |
|
164 |
pos = random.randint(0, 1) |
|
165 |
||
166 |
# default color |
|
5
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
167 |
if not color : |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
168 |
color = "#000000" |
16 | 169 |
|
170 |
# randomize text in some way? |
|
9 | 171 |
if random_text : |
172 |
line = ''.join(randomize(line)) |
|
11 | 173 |
|
174 |
if random_text_char : |
|
175 |
line = randomize_str_char(line) |
|
0 | 176 |
|
177 |
# split into three parts |
|
5
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
178 |
if char : |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
179 |
data.append([ |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
180 |
(line[:pos], "#000000"), |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
181 |
(char, color), |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
182 |
(line[pos:], "#000000"), |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
183 |
]) |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
184 |
else : |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
185 |
data.append([ |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
186 |
(line, "#000000"), |
6d0e03f2fef4
replace zip with itertools.izip_longest
Tero Marttila <terom@fixme.fi>
parents:
4
diff
changeset
|
187 |
]) |
0 | 188 |
|
189 |
return data |
|
190 |
||
191 |
def load_font (font_name, font_size) : |
|
192 |
""" |
|
193 |
Load a font by name |
|
194 |
""" |
|
195 |
||
196 |
# load font |
|
8 | 197 |
font_path = FONTS[font_name] |
0 | 198 |
font = ImageFont.truetype(font_path, font_size) |
199 |
||
200 |
return font |
|
201 |
||
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
202 |
def render_img (data, font, background_color="#ffffff", line_spacing=0, img_size=None) : |
0 | 203 |
""" |
204 |
Render the data (as from build_data) as an image, using the given PIL.ImageFont, and return the PIL Image object |
|
205 |
""" |
|
206 |
||
207 |
img_width = img_height = 0 |
|
208 |
||
209 |
img_data = [] |
|
210 |
||
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
211 |
# compute image/segment width/height |
0 | 212 |
for segments in data : |
213 |
line_width = line_height = 0 |
|
214 |
||
215 |
# build a new list of segments with additional info |
|
216 |
line_segments = [] |
|
217 |
||
218 |
for seg_text, seg_color in segments : |
|
219 |
# compute rendered text size |
|
220 |
seg_width, seg_height = font.getsize(seg_text) |
|
221 |
||
222 |
# update line_* |
|
223 |
line_width += seg_width |
|
224 |
line_height = max(line_height, seg_height) |
|
225 |
||
226 |
# build the new segments list |
|
227 |
line_segments.append((seg_text, seg_color, seg_width)) |
|
228 |
||
229 |
# update img_* |
|
230 |
img_width = max(img_width, line_width) |
|
231 |
img_height += line_height |
|
232 |
img_data.append((line_segments, line_height)) |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
233 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
234 |
if img_size : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
235 |
# override size |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
236 |
img_width, img_height = img_size |
0 | 237 |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
238 |
else : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
239 |
# calculate height needed for line spacing |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
240 |
img_height += (len(img_data) - 1) * line_spacing |
0 | 241 |
|
242 |
# create image |
|
243 |
img = Image.new("RGB", (img_width, img_height), background_color) |
|
244 |
draw = ImageDraw.Draw(img) |
|
245 |
||
246 |
# draw text |
|
247 |
img_y = 0 |
|
248 |
for segments, line_height in img_data : |
|
249 |
img_x = 0 |
|
250 |
||
251 |
# draw each segment build above, incremeing along img_x |
|
252 |
for seg_text, seg_color, seg_width in segments : |
|
253 |
draw.text((img_x, img_y), seg_text, font=font, fill=seg_color) |
|
254 |
||
255 |
img_x += seg_width |
|
256 |
||
257 |
img_y += line_height + line_spacing |
|
258 |
||
259 |
return img |
|
260 |
||
3 | 261 |
def effect_sharpness (img, factor) : |
1
71c7382994c4
rename logo.py -> index.cgi, and implement blurring
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
262 |
""" |
3 | 263 |
Sharpen the image by the given factor |
1
71c7382994c4
rename logo.py -> index.cgi, and implement blurring
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
264 |
""" |
71c7382994c4
rename logo.py -> index.cgi, and implement blurring
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
265 |
|
71c7382994c4
rename logo.py -> index.cgi, and implement blurring
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
266 |
return ImageEnhance.Sharpness(img).enhance(factor) |
71c7382994c4
rename logo.py -> index.cgi, and implement blurring
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
267 |
|
7 | 268 |
def build_img (img, format='png') : |
0 | 269 |
""" |
270 |
Write the given PIL.Image as a string, returning the raw binary data |
|
7 | 271 |
|
272 |
Format should be one of the PIL-supported image foarts |
|
0 | 273 |
""" |
274 |
||
275 |
# render PNG output |
|
276 |
buf = StringIO() |
|
7 | 277 |
img.save(buf, format) |
0 | 278 |
data = buf.getvalue() |
279 |
||
280 |
return data |
|
281 |
||
16 | 282 |
class OptionType (object) : |
283 |
def parse (self, val) : |
|
284 |
""" |
|
285 |
Unicode value -> object |
|
286 |
""" |
|
3 | 287 |
|
16 | 288 |
abstract |
3 | 289 |
|
16 | 290 |
def build (self, val) : |
291 |
""" |
|
292 |
object -> unicode value |
|
293 |
""" |
|
294 |
||
295 |
return unicode(val) |
|
296 |
||
297 |
def input (self, val) : |
|
298 |
""" |
|
299 |
HTML input item |
|
300 |
""" |
|
301 |
||
302 |
abstract |
|
303 |
||
304 |
class StringOption (OptionType) : |
|
305 |
def parse (self, val) : |
|
306 |
return unicode(val) |
|
307 |
||
308 |
def build (self, val) : |
|
309 |
if val is None : |
|
310 |
return "" |
|
311 |
||
312 |
else : |
|
313 |
return val |
|
314 |
||
315 |
def input (self, opt, val) : |
|
316 |
return """<input type="text" name="%(name)s" id="%(name)s" value="%(value)s" />""" % dict( |
|
317 |
name = opt.name, |
|
318 |
value = self.build(val), |
|
319 |
) |
|
320 |
||
321 |
def select (self, opt, val) : |
|
322 |
return """<select name="%(name)s"> |
|
323 |
%(options)s |
|
324 |
</select>""" % dict( |
|
325 |
name = opt.name, |
|
326 |
options = '\n'.join( |
|
327 |
"\t<option %(selected)s>%(value)s</option>" % dict( |
|
328 |
value = self.build(optval), |
|
329 |
selected = 'selected="selected"' if val == optval else "", |
|
330 |
) for optval in opt.range |
|
331 |
), |
|
332 |
) |
|
333 |
||
334 |
class BoolOption (OptionType) : |
|
335 |
def parse (self, val) : |
|
336 |
if val.lower() in ('true', 't', '1', 'yes', 'y') : |
|
337 |
return True |
|
338 |
||
339 |
elif val.lower() in ('false', 'f', '0', 'no', 'n') : |
|
340 |
return False |
|
341 |
||
342 |
else : |
|
343 |
raise ValueError(val) |
|
344 |
||
345 |
def input (self, opt, val) : |
|
346 |
return """<input type="checkbox" name="%(name)s" id="%(name)s" %(checked)s/>""" % dict( |
|
347 |
name = opt.name, |
|
348 |
checked = 'checked="checked"' if val else '', |
|
349 |
) |
|
350 |
||
351 |
class IntOption (StringOption) : |
|
352 |
def parse (self, val) : |
|
353 |
return int(val) |
|
354 |
||
355 |
class FloatOption (StringOption) : |
|
356 |
def parse (self, val) : |
|
357 |
return float(val) |
|
358 |
||
359 |
class ColorOption (StringOption) : |
|
360 |
def _parse (self, val) : |
|
361 |
if val.startswith('#') : |
|
362 |
int(val[1:], 16) |
|
363 |
||
364 |
return val |
|
365 |
else : |
|
366 |
raise ValueError(val) |
|
367 |
||
3 | 368 |
|
8 | 369 |
class Option (object) : |
370 |
def __init__ (self, name, is_list, type, default, range) : |
|
371 |
self.name = name |
|
372 |
self.is_list = is_list |
|
373 |
self.type = type |
|
374 |
self.default = default |
|
375 |
self.range = range |
|
3 | 376 |
|
16 | 377 |
def parse (self, args, force_bool=False) : |
8 | 378 |
if self.is_list : |
379 |
if self.name in args : |
|
16 | 380 |
l = args.getlist(self.name, self.type.parse) |
381 |
||
382 |
# special-case to handle a single param with a newline-separtated list |
|
383 |
if len(l) == 1 : |
|
384 |
if not l[0] : |
|
385 |
return None |
|
386 |
||
387 |
else : |
|
388 |
return l[0].split('\r\n') |
|
389 |
||
390 |
else : |
|
391 |
return l |
|
392 |
||
8 | 393 |
else : |
394 |
return self.default |
|
16 | 395 |
|
8 | 396 |
else : |
16 | 397 |
if isinstance(self.type, BoolOption) and force_bool : |
398 |
return self.name in args |
|
399 |
||
400 |
elif isinstance(self.type, BoolOption) and not self.default and self.name in args : |
|
10
6add80d3993b
enable arg_bools by just giving an empty opt
Tero Marttila <terom@fixme.fi>
parents:
9
diff
changeset
|
401 |
return True |
6add80d3993b
enable arg_bools by just giving an empty opt
Tero Marttila <terom@fixme.fi>
parents:
9
diff
changeset
|
402 |
|
6add80d3993b
enable arg_bools by just giving an empty opt
Tero Marttila <terom@fixme.fi>
parents:
9
diff
changeset
|
403 |
else : |
16 | 404 |
return args.get(self.name, self.default, self.type.parse) |
405 |
||
406 |
def build_list (self, value) : |
|
407 |
if self.is_list and value : |
|
408 |
return [self.type.build(val) for val in value] |
|
409 |
||
410 |
else : |
|
411 |
return [self.type.build(value)] |
|
412 |
||
413 |
def _build_input (self, value) : |
|
414 |
if self.is_list : |
|
415 |
return """\ |
|
416 |
<textarea name="%(name)s" cols="30">\ |
|
417 |
%(data)s\ |
|
418 |
</textarea>""" % dict( |
|
419 |
name = self.name, |
|
420 |
data = '\n'.join(self.type.build(val) for val in value) if value else '', |
|
421 |
) |
|
422 |
||
423 |
elif self.range : |
|
424 |
return self.type.select(self, value) |
|
425 |
||
426 |
else : |
|
427 |
return self.type.input(self, value) |
|
428 |
||
429 |
def build_form (self, opts) : |
|
430 |
value = opts[self.name] |
|
431 |
||
432 |
return """\ |
|
433 |
<div class="param"><label for="%(name)s">%(title)s</label>%(input)s</div>\ |
|
434 |
""" % dict( |
|
435 |
name = self.name, |
|
436 |
title = self.name.title().replace('-', ' '), |
|
437 |
input = self._build_input(value) |
|
438 |
) |
|
3 | 439 |
|
8 | 440 |
class Options (object) : |
441 |
def __init__ (self, *options) : |
|
16 | 442 |
self.options = list(options) |
443 |
self.options_by_name = dict((opt.name, opt) for opt in options) |
|
6 | 444 |
|
16 | 445 |
def parse (self, args, **kwargs) : |
446 |
return dict((opt.name, opt.parse(args, **kwargs)) for opt in self.options) |
|
8 | 447 |
|
448 |
OPTIONS = Options( |
|
16 | 449 |
Option('lang', False, StringOption(), Defaults.text_lang, TEXT_BY_LANG.keys()), |
450 |
Option('text', True, StringOption(), None, None), |
|
451 |
Option('random-text', False, BoolOption(), False, None), |
|
452 |
Option('random-text-char',False,BoolOption(), False, None), |
|
453 |
Option('chars', True, StringOption(), Defaults.chars, None), |
|
454 |
Option('random-chars', False, BoolOption(), True, None), |
|
455 |
Option('colors', True, ColorOption(), Defaults.colors, None), |
|
456 |
Option('font', False, StringOption(), Defaults.font_name, FONTS.keys()), |
|
457 |
Option('font-size', False, IntOption(), Defaults.font_size, None), |
|
458 |
Option('bg-color', False, ColorOption(), Defaults.bg_color, None), |
|
459 |
Option('line-spacing', False, IntOption(), Defaults.line_spacing, None), |
|
460 |
Option('sharpness', False, FloatOption(), Defaults.sharpness, None), |
|
461 |
Option('image-format', False, StringOption(), Defaults.img_format, IMAGE_FORMATS.keys()), |
|
462 |
Option('seed', False, IntOption(), None, None), |
|
19 | 463 |
Option('img-width', False, IntOption(), None, None), |
464 |
Option('img-height', False, IntOption(), None, None), |
|
8 | 465 |
) |
466 |
||
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
467 |
def handle_generic (req, img_size=None) : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
468 |
# parse options |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
469 |
opts = OPTIONS.parse(req.args) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
470 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
471 |
# postprocess |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
472 |
if opts['text'] is None : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
473 |
opts['text'] = TEXT_BY_LANG[opts['lang']] |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
474 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
475 |
if opts['font-size'] > FONT_SIZE_MAX : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
476 |
raise ValueError(opts['font-size']) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
477 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
478 |
if opts['seed'] is None : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
479 |
opts['seed'] = time.time() |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
480 |
|
19 | 481 |
if opts['img-width'] and opts['img-height'] : |
482 |
img_size = (opts['img-width'], opts['img-height']) |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
483 |
|
19 | 484 |
if opts['img-width'] > IMG_SIZE_MAX or opts['img-height'] > IMG_SIZE_MAX : |
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
485 |
raise ValueError(img_size) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
486 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
487 |
# load/prep resources |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
488 |
random.seed(opts['seed']) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
489 |
data = build_data(opts['text'], opts['chars'], opts['colors'], opts['random-chars'], opts['random-text'], opts['random-text-char']) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
490 |
font = load_font(opts['font'], opts['font-size']) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
491 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
492 |
# render the image |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
493 |
img = render_img(data, font, opts['bg-color'], opts['line-spacing'], img_size) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
494 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
495 |
img = effect_sharpness(img, opts['sharpness']) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
496 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
497 |
png_data = build_img(img, opts['image-format']) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
498 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
499 |
# build the response |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
500 |
response = werkzeug.Response(png_data, mimetype='image/%s' % opts['image-format']) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
501 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
502 |
return response |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
503 |
|
8 | 504 |
def handle_help (req) : |
505 |
return werkzeug.Response('\n'.join( |
|
506 |
"%-15s %4s %-10s %-20s %s" % data for data in [ |
|
507 |
("name", "", "type", "default", "range"), |
|
508 |
("", "", "", "", ""), |
|
509 |
] + [( |
|
510 |
opt.name, |
|
511 |
'list' if opt.is_list else 'item', |
|
512 |
opt.type.__name__, |
|
513 |
repr(opt.default), |
|
514 |
opt.range if opt.range else "" |
|
515 |
) for opt in OPTIONS.options] |
|
516 |
), mimetype='text/plain') |
|
517 |
||
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
518 |
def handle_logo (req) : |
8 | 519 |
if 'help' in req.args : |
520 |
return handle_help(req) |
|
12 | 521 |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
522 |
return handle_generic(req) |
3 | 523 |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
524 |
def handle_tile (req) : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
525 |
return handle_generic(req, img_size=TILE_SIZE) |
3 | 526 |
|
16 | 527 |
def handle_index (options, req) : |
528 |
# parse options, force booleans if any form data was submitted, as checkboxes work that way |
|
529 |
opts = options.parse(req.values, force_bool=bool(req.form)) |
|
530 |
||
531 |
# build query string of req things |
|
532 |
qargs = [ |
|
533 |
(opt.name, opt.build_list(val)) for opt, val in ( |
|
534 |
(options.options_by_name[opt_name], val) for opt_name, val in opts.iteritems() |
|
535 |
) if val != opt.default |
|
536 |
] |
|
537 |
||
538 |
img_url = req.url_root + "logo" + ("?%s" % werkzeug.url_encode(qargs) if qargs else '') |
|
539 |
||
540 |
return werkzeug.Response("""\ |
|
541 |
<html> |
|
542 |
<head> |
|
543 |
<title>Aaltologotin</title> |
|
544 |
<style type="text/css"> |
|
545 |
div#logo { |
|
546 |
text-align: center; |
|
547 |
padding: 100px; |
|
548 |
} |
|
549 |
||
550 |
img { |
|
551 |
border: none; |
|
552 |
} |
|
553 |
||
554 |
div#info { |
|
555 |
font-size: small; |
|
556 |
padding-left: 25px; |
|
557 |
margin-top: 50px; |
|
558 |
color: grey; |
|
559 |
} |
|
560 |
||
561 |
label { |
|
562 |
display: block; |
|
563 |
float: left; |
|
564 |
||
565 |
width: 150px; |
|
566 |
} |
|
567 |
||
568 |
div.param { |
|
569 |
padding: 3px; |
|
570 |
} |
|
18 | 571 |
|
572 |
div#footer { |
|
573 |
text-align: center; |
|
574 |
font-size: x-small; |
|
575 |
font-style: italic; |
|
576 |
} |
|
16 | 577 |
</style> |
578 |
</head> |
|
579 |
<body> |
|
580 |
<div id='logo'> |
|
581 |
<a href="%(img_url)s"><img src="%(img_url)s" alt="Aaltologo" /></a> |
|
582 |
</div> |
|
583 |
<div id='info'> |
|
584 |
<h1>Aaltologotin</h1> |
|
585 |
<p>Aaltologotin pulauttaa sulle uuden, sattumanvaraisesti valitun aalto-logon!</p> |
|
586 |
||
17 | 587 |
<form action="%(script_url)s" method="POST"> |
16 | 588 |
<fieldset> |
589 |
<legend>Aalto-parameterit</legend> |
|
590 |
%(form_fields)s |
|
591 |
<input type="submit" value="Logota!" /> |
|
592 |
</fieldset> |
|
593 |
</form> |
|
594 |
</div> |
|
18 | 595 |
<div id='footer'> |
596 |
<a href="%(site_url)s">Aaltologotin</a> © 2009 Tero Marttila :: GPL <a href="%(source_url)s">Source code</a> |
|
597 |
</div> |
|
16 | 598 |
</body> |
599 |
</html>""" % dict( |
|
600 |
img_url = img_url, |
|
17 | 601 |
script_url = req.url_root, |
16 | 602 |
form_fields = "\n".join( |
603 |
"\t%s" % opt.build_form(opts) for opt in options.options |
|
604 |
), |
|
18 | 605 |
site_url = SITE_URL, |
606 |
source_url = SOURCE_URL, |
|
16 | 607 |
), mimetype='text/html') |
608 |
||
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
609 |
def handle_request (req) : |
16 | 610 |
if req.path == '/' : |
611 |
return handle_index(OPTIONS, req) |
|
612 |
||
613 |
elif req.path.startswith('/logo') : |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
614 |
return handle_logo(req) |
3 | 615 |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
616 |
elif req.path == '/tile' : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
617 |
return handle_tile(req) |
3 | 618 |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
619 |
else : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
620 |
raise ValueError(req) |
3 | 621 |
|
622 |
@werkzeug.Request.application |
|
623 |
def wsgi_application (request) : |
|
0 | 624 |
""" |
3 | 625 |
Our werkzeug WSGI handler |
0 | 626 |
""" |
627 |
||
3 | 628 |
try : |
629 |
# request -> response |
|
630 |
response = handle_request(request) |
|
0 | 631 |
|
3 | 632 |
return response |
633 |
||
634 |
except HTTPException, e : |
|
635 |
# return as HTTP response |
|
636 |
return e |
|
0 | 637 |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
638 |
def build_app () : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
639 |
""" |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
640 |
Build and return a WSGI application |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
641 |
""" |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
642 |
|
3 | 643 |
app = wsgi_application |
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
644 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
645 |
# add other middleware |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
646 |
app = werkzeug.SharedDataMiddleware(app, { |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
647 |
'/static': STATIC_PATH, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
648 |
}) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
649 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
650 |
|
6 | 651 |
if DEBUG : |
3 | 652 |
# enable debugging |
653 |
app = werkzeug.DebuggedApplication(app, evalex=False) |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
654 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
655 |
return app |
0 | 656 |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
657 |
def main_cgi (app) : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
658 |
import wsgiref.handlers |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
659 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
660 |
handler = wsgiref.handlers.CGIHandler() |
3 | 661 |
handler.run(app) |
0 | 662 |
|
13
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
663 |
def main_fastcgi (app) : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
664 |
import flup.server.fcgi |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
665 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
666 |
server = flup.server.fcgi.WSGIServer(app, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
667 |
multithreaded = False, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
668 |
multiprocess = False, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
669 |
multiplexed = False, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
670 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
671 |
bindAddress = None, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
672 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
673 |
umask = None, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
674 |
debug = True, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
675 |
) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
676 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
677 |
server.run() |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
678 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
679 |
def main () : |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
680 |
from sys import argv |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
681 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
682 |
# get our file extension |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
683 |
root, ext = os.path.splitext(argv[0]) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
684 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
685 |
# get our handler |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
686 |
handler = { |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
687 |
'.cgi': main_cgi, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
688 |
'.fcgi': main_fastcgi, |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
689 |
}[ext] |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
690 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
691 |
# get our app |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
692 |
app = build_app() |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
693 |
|
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
694 |
# run |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
695 |
handler(app) |
a0cb32f3de3d
add silly crap (FastCGI, tiles.*)
Tero Marttila <terom@fixme.fi>
parents:
12
diff
changeset
|
696 |
|
0 | 697 |
if __name__ == '__main__' : |
698 |
main() |
|
699 |