Flask 淘宝数据再开发WEB,flask淘宝开发web,https://gith


https://github.com/thomashuang/taobao-abc

Flask 一个简单的淘宝数据分析再利用web应用

主要的Model完成,有兴趣的可以试试

#!/usr/bin/python2.7# -*- coding: utf-8 -*-import jsonfrom flask import Flask, session, g, render_templatefrom flask.sessions import SecureCookieSession, SecureCookieSessionInterfacefrom models.model import Modelimport settingsclass JSONSecureCookieSession(SecureCookieSession):    serialization_method = jsonclass JSONSecureCookieSessionInterface(SecureCookieSessionInterface):    session_class = JSONSecureCookieSessionapp = Flask(__name__)app.secret_key = "I-like-cookies-and-some-secure-cookies"app.session_interface = JSONSecureCookieSessionInterface()app.debug = Truedef init_db_settings():    """initialize database the database tables."""    Model.initailize(settings.db_setting)@app.before_requestdef before_request():    """    pull user's profile from the database before every request are treated    """    g.user = None    if 'member_auth' in session:        g.user = session.get('member_auth')@app.route(r'/')def index():    return render_template("index.html", user = g.user)@app.route(r'/v')def v():    return render_template("v.html")@app.route(r'/fav')def fav():    return render_template('fav.html')@app.route(r'/c')def c():    return render_template('c.html')@app.route(r'/l')def l():    return render_template('l.html')if __name__ == '__main__':    init_db_settings()    app.run()#该片段来自于http://byrx.net

评论关闭