-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
42 lines (33 loc) · 1.05 KB
/
config.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
41
42
from bottle import request
from datetime import datetime
from beaker.middleware import SessionMiddleware
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static').replace('\\', '/')
STORE_ROOT = os.path.join(PROJECT_ROOT, 'store').replace('\\', '/')
def getfilepath(dirname,filename):
## return abspath
FPATH_ROOT=os.path.join(PROJECT_ROOT,dirname).replace('\\','/')
filepath=FPATH_ROOT+'/'+filename
return filepath
def baseinfo():
# base infomation name,year,auth,nick,avatar
bf=info()
session=request.environ.get('beaker.session')
if session:
bf.user=session.get('name')
bf.auth=session.get('auth')
bf.id=session.get('id')
else:
bf.auth=False
return bf
class info:
def __init__(self):
self.name="Python Train"
self.year=datetime.now().year
self.auth=False
self.id=""
self.user="Guest"
self.avatar='/static/avatar/river.jpg'
self.title=""
self.writer="温州水乡"