File: webAppTest.py

package info (click to toggle)
thawab 4.1-2
  • links: PTS, VCS
  • area: non-free
  • in suites: bullseye, sid
  • size: 1,912 kB
  • sloc: python: 4,041; makefile: 134; sh: 33
file content (28 lines) | stat: -rwxr-xr-x 946 bytes parent folder | download
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
#! /usr/bin/python
# -*- coding: UTF-8 -*-
import sys, os, os.path, logging
import Thawab.core
from Thawab.webApp import webApp, get_theme_dirs

prefix=os.path.dirname(sys.argv[0])
th=Thawab.core.ThawabMan()

myLogger=logging.getLogger('ThawabWebAppTest')
h=logging.StreamHandler() # in production use WatchedFileHandler or RotatingFileHandler
h.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
myLogger.addHandler(h)
myLogger.setLevel(logging.INFO)

from paste import httpserver

lookup=[os.path.join(prefix,'thawab-themes')]
lookup.extend([os.path.join(i, 'themes') for i in th.prefixes])
app=webApp(
  th,'web', 
  lookup, th.conf.get('theme','default'), '/_theme/',
  logger=myLogger
  );
# for options see http://pythonpaste.org/modules/httpserver.html
httpserver.serve(app, host='0.0.0.0', port='8080') # to serve publically
#httpserver.serve(app, host='127.0.0.1', port='8080') # to serve localhost