-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtestapp
More file actions
61 lines (48 loc) · 1.42 KB
/
Copy pathtestapp
File metadata and controls
61 lines (48 loc) · 1.42 KB
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
60
61
#!/usr/bin/env python2
import urllib
import cherrypy
import re
import sqlite3
import os
import json
import sys
from jinja2 import Template, Environment, FileSystemLoader
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
DBPATH = os.path.join(PROJECT_PATH, 'entries.db')
SESSION_FILE_PATH = os.path.join(PROJECT_PATH, 'session_data/')
STATICDIR = PROJECT_PATH
sys.path.append(PROJECT_PATH)
try:
from local_settings import *
except ImportError:
pass
env = Environment(loader=FileSystemLoader(os.path.join(PROJECT_PATH, 'templates')))
class CherryStart(object):
_cp_config = {'tools.sessions.on': True,
'tools.sessions.timeout': 60*24,
'tools.sessions.storage_type': "file",
'tools.sessions.storage_path': SESSION_FILE_PATH,
}
def __init__(self):
pass
@cherrypy.expose
def index(self):
context = dict()
tmpl = env.get_template('index.html')
return tmpl.render(context)
conf = {
'/': {
'tools.encode.on': True,
'tools.encode.encoding' : 'utf-8',
'tools.gzip.on': True,
},
'/media': {
'tools.staticdir.on': True,
'tools.staticdir.dir': 'media',
'tools.staticdir.root': STATICDIR,
},
}
if __name__=='__main__':
cherrypy.server.socket_host = '0.0.0.0'
cherrypy.quickstart(CherryStart(), config=conf)
application = cherrypy.Application(CherryStart(), script_name=None, config=conf)