def _install_plugin(self): """ 初始化插件 """ install_redis_plugin(self.app) install_session_plugin(self.app)
#!/usr/bin/python """ Author:$Author$ Date:$Date$ Revision:$Revision$ Description: 后台APP应用入口 """ from bottle import Bottle from common.install_plugin import install_redis_plugin, install_session_plugin admin_app = Bottle() install_redis_plugin(admin_app) install_session_plugin(admin_app) import admin_index import admin_auth #会员模块 import admin_member # 数据统计模块 import admin_statistics # 个人信息模块 import admin_self # 代理模块 import admin_agent # 用户权限模块 import admin_power #游戏模块
from model import mysql from decimal import Decimal #from pyinapp import * ACCEPT_NUM_BASE = 198326 ACCEPT_TT = [md5.new(str(ACCEPT_NUM_BASE+i)).hexdigest() for i in xrange(10)] SESSION_TTL = 60*60 CHECK_SUCCESS = 1 #生成捕鱼APP fish_app = Bottle() #获取配置 conf = default_app().config #安装插件 install_redis_plugin(fish_app) install_session_plugin(fish_app) import fish_broad import fish_invite import fish_pay import fish_exchange FORMAT_PARAMS_POST_STR = "%s = request.forms.get('%s','').strip()" FORMAT_PARAMS_GET_STR = "%s = request.GET.get('%s','').strip()" #用户信息 USER_INFO = ('headImgUrl', 'sex', 'isVolntExitGroup','coin','exchange_ticket') DEFAULT_AGENT_ID = '540302' # DEFAULT_AGENT_ID = '000000'
initializeWeb() #模板 bottle.TEMPLATE_PATH.append('mahjong/template/%s' % (TEMPLATE_NAME)) random.seed() #主应用 main_app = bottle.default_app() #配置文件 config_file = 'conf_release.json' # #从json中读取配置文件 with open(config_file) as f: main_app.config.load_dict(json.load(f)) #安装插件 install_redis_plugin(main_app) install_session_plugin(main_app) if main_app.config.get('download_view', 1): @main_app.get('/download/<res_path:path>') def download_path(res_path): ''' @description: 是否允许下载 ''' return bottle.static_file(res_path, root=DOWNLOAD_PATH, download=True) @main_app.get('/<res_path:path>') def content_path(res_path): '''
游戏入口 """ from bottle import request, Bottle, abort, redirect, response, template,static_file from db_define import * from weixin_data import * from talk_data import sendTalkData from common.install_plugin import install_redis_plugin from common.log import * import urllib2 import json import random entry_app = Bottle() #安装插件 install_redis_plugin(entry_app) import md5 ACCEPT_NUM_BASE = 198326 MAX_COUNTRY_CODE_TTL = 7*24*3600 ACCEPT_TT = [md5.new(str(ACCEPT_NUM_BASE+i)).hexdigest() for i in xrange(10)] GET_IP_AREA_URL = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" """ 自动获取服务器地址接口,返回一个合适的游戏服务器ip及port给客户端 # post # request sample: http://<server>/game/getServer params: [tt]md5一个随机范围在198326-198335的数字做校验,简单规避爬虫等攻击尝试 [room]房间号,发送此字段则获得房间所在ip [gameId]
from db_define import * from wechatData import * from common.install_plugin import install_redis_plugin #from common.log import * from datetime import datetime import time import urllib2 import json import random import md5 #wechatApp wechat_app = Bottle() #安装插件 install_redis_plugin(wechat_app) @wechat_app.post('/onReg') def onReg(redis): #传入参数:账号,密码,类型;返回参数:成功返回账号和密码,失败返回None, None curTime = datetime.now() account = request.forms.get('account','').strip() passwd = request.forms.get('passwd','').strip() type = request.forms.get('type','').strip() #print print '[%s][wechat onReg][info] account[%s] passwd[%s] type[%s]'%(curTime,account,passwd,type) log_debug('[%s][wechat onReg][info] account[%s] passwd[%s] type[%s]'%(curTime,account,passwd,type)) if type == 1: #微信code登录 tokenMessage = checkWeixinCode(account)
#-*- coding:utf-8 -*- #!/usr/bin/python """ Author:$Author$ Date:$Date$ Revision:$Revision$ Description: 后台activice应用入口 """ from bottle import Bottle from common.install_plugin import install_redis_plugin,install_session_plugin activice_app = Bottle() install_redis_plugin(activice_app) install_session_plugin(activice_app)
from common.install_plugin import install_redis_plugin, install_session_plugin #from common.log import * from datetime import datetime import time import urllib2 import json import random import md5 ACCEPT_NUM_BASE = 198326 ACCEPT_TT = [md5.new(str(ACCEPT_NUM_BASE + i)).hexdigest() for i in xrange(10)] #wechatApp hall_app = Bottle() #安装插件 install_redis_plugin(hall_app) install_session_plugin(hall_app) def onReg(redis, account, passwd, type): #传入参数:账号,密码,类型;返回参数:成功返回账号和密码,失败返回None, None curTime = datetime.now() #print print '[%s][wechat onReg][info] account[%s] passwd[%s] type[%s]' % ( curTime, account, passwd, type) if type == 1: #微信code登录 tokenMessage = checkWeixinCode(account) if tokenMessage: