def GET(self,uid): try: content = store.Code.get(uid) web.header("Content-Disposition","attachment; filename='%s.%s'"\ %(uid,langextset.get(content.lang,"txt"))) return content.content except: return render("error.html",error="no data")
def GET(self): web.header("Content-Type","text/html; charset=utf-8") page = int(web.input().get("page",1)) offset = (page-1)*pagesize tops = store.Post.where(status=0).order_by("modified desc")[offset:pagesize] return render("news_audit.html", tops = tops, page=page)
def GET(self): web.header("Content-Type","text/html; charset=utf-8") page = int(web.input().get("page",1)) offset = (page-1) * pagesize langs = store.Lang.where() tags = store.get_code_tags(30) tops = store.Code.where().order_by("create_time desc")[offset:offset+pagesize] return render("code.html",tops = tops,langs=langs,tags=tags,page=page)
def GET(self): web.header("Content-Type","text/html; charset=utf-8") session = web.ctx.session user = session.get("user") if not user: raise web.seeother("/") userobj = store.User.get(username=user.username) return render("user_settings.html",user=userobj)
def GET(self,tag): web.header("Content-Type","text/html; charset=utf-8") page = int(web.input().get("page",1)) offset = (page-1)*pagesize tags = store.get_project_tags(20) projs = store.Project.where("tags like %s",'%%%s%%'%tag).order_by("created desc")[offset:pagesize] return render("project.html", projs = projs, tags=tags, page=page)
def GET(self,tag): web.header("Content-Type","text/html; charset=utf-8") langs = store.Lang.where() posts = store.Post.where("tags like %s",'%%%s%%'%tag)[:50] codes = store.Code.where("tags like %s",'%%%s%%'%tag)[:50] tags = store.get_tags(30) return render("tags_list.html", langs = langs, posts=posts, codes=codes, tags=tags)
def GET(self,uid): web.header("Content-Type","text/html; charset=utf-8") try: page = int(web.input().get("page",1)) offset = (page-1) * pagesize versions = store.Code.where(parent=uid) [offset:pagesize] content = store.Code.get(id=uid) content.hits += 1 content.save() posts = store.Post.where(codeid=uid) comments = store.Comment.where(postid=uid).order_by("created desc")[offset:offset+pagesize] content.content = filter_html(content.content) return render("code_view.html", page=page, versions = versions, content=content, comments=comments, pagename=content.title, posts=posts) except: return render("error.html",error="no data")
def GET(self): web.header("Content-Type","text/html; charset=utf-8") page = int(web.input().get("page",1)) offset = (page-1)*pagesize stats = store.get_post_stats(False) tops = store.Post.where(status=1).order_by("modified desc")[offset:offset+pagesize] tags = store.get_post_tags(30) return render("news.html", tops = tops, stats=stats, tags=tags, page=page)
def GET(self,tag): web.header("Content-Type","text/html; charset=utf-8") page = int(web.input().get("page",1)) offset = (page-1)*pagesize tags = store.get_post_tags(30) stats = store.get_post_stats(tag) tops = store.Post.where("status=1 and tags like %s",'%%%s%%'%tag).order_by("modified desc")[offset:pagesize] return render("news.html", ctag=tag, tops = tops, stats=stats, tags=tags, page=page)
def GET(self): web.header("Content-Type","text/html; charset=utf-8") tops = store.Code.where().order_by("create_time desc")[:10] langs = store.Lang.where() stats = store.get_post_stats(False) posts = store.Post.where(status=1).order_by("created desc")[:pagesize] codetags = store.get_code_tags(30) posttags = store.get_post_tags(30) return render("index.html", tops = tops, posts=posts, langs=langs, stats=stats, codetags=codetags, posttags=posttags)
def GET(self,uid): web.header("Content-Type","text/html; charset=utf-8") page = int(web.input().get("page",1)) offset = (page-1)*pagesize try: proj = store.Project.get(uid) proj.hits += 1 proj.save() comments = store.Comment.where(postid=uid).order_by("created desc")[offset:pagesize] return render("project_view.html", proj = proj, comments=comments, page=page) except Exception, e: return errorpage("view project error %s"%e)
def get(self, padName, group, timestamp): ethGid = createGroupIfNotExistsFor(group) time = parseTimestamp(timestamp) # Remove whitespaces on beginning and end padName = settings.render(padName.strip(), time).replace(' ', '_') # Padname has at least 3 characters if len(padName) < 3: return { 'code' : 7, 'message' : 'Mach den Namen mal laenger' } if not bool(re.match(r'.*[a-zA-z]{1,}', padName)): return { 'code' : 6, 'message' : 'Probiere es mal mit Buchstaben' } return createGroupPad(ethGid, padName)
def GET(self,uid): web.header("Content-Type","text/html; charset=utf-8") try: page = int(web.input().get("page",1)) post = store.Post.get(uid) post.hits += 1 post.save() tags = store.get_post_tags(30) codeid = post.codeid code = None if codeid: code = store.Code.get(codeid) comments = store.Comment.where(postid=uid).order_by("created desc")[(page-1)*pagesize:pagesize] return render("post_view.html", tags=tags, post=post, comments=comments, page=page, code=code, pagename=post.title) except Exception,e: return errorpage("error %s"%e)
def sell_5A(m=5): content = request.forms.content content = [line.lstrip().rstrip() for line in content.split('\n') if len(line)>10] all_d = [] for line in content: sp = line.split('\t') d , n1, n2, n3, n4 = sp d = datetime.strptime(d, '%Y-%m-%d %H:%M') n1 = float(n1) n2 = float(n2) n3 = float(n3) n4 = float(n4) all_d.append((d, n1 + n2 + n3 + n4)) dt0 = datetime(2010, 1, 1) ts = lambda d: int((d - dt0).total_seconds()) gk = lambda d: ts(d[0]) / (60 * m) dic = group(all_d, gk) dic = dict([(k, sum([ a[1] for a in arr])) for k, arr in dic.iteritems()]) dic_all = dict([(a, 0) for a in xrange(min(dic.iterkeys()), max(dic.iterkeys())+1)]) dic = dict(dic_all, **dic) ds_str = lambda x: (dt0 + timedelta(minutes=x*m)).strftime('%H:%M') dd = [ [ds_str(k), v, 0] for k, v in dic.iteritems()] dd = sorted(dd, key=lambda x: x[0]) return render('lff/sell5', dict(content=request.forms.content, js=json.dumps(dd), title=u'销售5分图'))
def GET(self): web.header("Content-Type","text/html; charset=utf-8") langs = store.Lang.where() return render("code_add.html",langs = langs)
def GET(self): web.header("Content-Type","text/xml; charset=utf-8") tops = store.Code.where().order_by("create_time desc")[:100] return render("codefeed.html",tops = tops,lastBuildDate=store.currtime())
import web import os, sys lib_path = os.path.abspath('../') sys.path.append(lib_path) from models import database, profile from settings import db, render db = db() render = render() class hello: def GET(self): password = db.query("SELECT * FROM profile")[0] halo = profile.getUser() return render.index(halo=halo, password = password) class page: def GET(self): return render.page()
def sell5_get(m=5): return render('lff/sell5', dict(js='[]', min='null', title=u'销售5分图'))
def sell5(m=None): content = request.forms.content log4.info('lff/sell5', content) content = [line.lstrip().rstrip() for line in content.split('\n') if len(line)>10] all_d = [] for line in content: sp = line.split('\t') d , n1, n2, n3, n4 = sp d = datetime.strptime(d, '%Y-%m-%d %H:%M') n1 = float(n1) n2 = float(n2) n3 = float(n3) n4 = float(n4) all_d.append((d, n1 + n2 + n3 + n4)) dt0 = datetime(2010, 1, 1) ts = lambda d: int((d - dt0).total_seconds()) gk = lambda d: ts(d[0]) / 60 dic = group(all_d, gk) dic = dict([(k, sum([ a[1] for a in arr])) for k, arr in dic.iteritems()]) dic_all = dict([ (a, 0) for a in xrange(min(dic.iterkeys()), max(dic.iterkeys())+1)]) dic = dict(dic_all, **dic) ds_str = lambda x: (dt0 + timedelta(minutes=x)).strftime('%H:%M') dd = [[ds_str(k), v, 0] for k, v in dic.iteritems()] dd = sorted(dd, key=lambda x: x[0]) subs = [] for i in xrange(len(dd)-5): subs.append(dd[i:i+5]) min_grp = None for sub in subs: ss = sum([ b for a, b, c in sub]) if ss == 0: min_grp = sub break if min_grp is None: min_grp = sub continue if min_grp and sum([ b for a, b, c in min_grp]) > ss: min_grp = sub mxsell = max([ v for s, v, x in dd]) for d in dd: d[2] = 0 - mxsell / 10 for sub in min_grp: if d[0] == sub[0]: d[2] = 0 - mxsell / 2 bag = dict(content=request.forms.content, js=json.dumps(dd), title=u'销售5分图') bag['min'] = sum([ b for a, b, c in min_grp]) return render('lff/sell5', bag) """
def GET(self): web.header("Content-Type","text/html; charset=utf-8") return render("login.html")
def GET(self): web.header("Content-Type","text/html; charset=utf-8") codeid = web.input().get("codeid") return render("post_add.html",codeid=codeid)
def GET(self): '''sitemaps''' web.header("Content-Type","text/xml; charset=utf-8") urls = store.sitemap_data() return render("sitemaps.xml",urls=urls)
def GET(self): web.header("Content-Type","text/xml; charset=utf-8") tops = store.Post.where(status=1).order_by("modified desc")[:50] return render("newsfeed.html",tops = tops,lastBuildDate=store.currtime())