forked from linuxscout/mishkal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mishkal-webserver.py
executable file
·40 lines (35 loc) · 1.24 KB
/
mishkal-webserver.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
#! /usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import os
import os.path
import re
from glob import glob
sys.path.append('mishkal/');
sys.path.append('mishkal/lib/');
sys.path.append('lib/web');
from okasha2.baseWebApp import *
from okasha2.utils import fromFs, toFs
from adawaty import *
def test():
# this requires python-paste package
import logging
from paste import httpserver
d=fromFs(os.path.dirname(sys.argv[0]))
LOG_FILENAME = os.path.join(d,u'tmp','logging_example.out')
logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO,)
myLogger=logging.getLogger('MyTestWebApp')
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) # in production use logging.INFO
d=fromFs(os.path.dirname(sys.argv[0]))
app=webApp(
os.path.join(d,u'resources/templates'),
staticBaseDir={u'/_files/':os.path.join(d,u'resources/files')},
logger=myLogger
);
# for options see http://pythonpaste.org/modules/httpserver.html
httpserver.serve(app, host='0.0.0.0', port='8080')
if __name__ == '__main__':
test();