Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrela committed Feb 8, 2018
1 parent 8e25907 commit 3b68717
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 18 deletions.
Binary file removed 1.png
Binary file not shown.
Binary file removed 2.png
Binary file not shown.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
1. 首先安装Python。linux自带了python,windows请自行下载python。推荐Centos7/Python2.7
2. 这时候,pip应该可以用了。如果不行,linux请按下面的命令安装pip:
`wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py`
3. 安装依赖库:`pip install -r requirement.txt`
4. 创建一个`logs`目录: `mkdir logs`
4. 创建数据库:`python rebuildDB.py`
5. 安装`redis`:建议先安装宝塔,然后直接用宝塔安装redis
6. 网站目录下运行:`gunicorn -w4 -b 0.0.0.0:5000 run:app`
3. `/root`目录下解压/git clone下源码:`git clone https://github.com/tangrela/ojbk_jiexi.git`
4. 安装依赖库:`cd ojbk_jiexi && pip install -r requirement.txt`
5. 创建一个`logs`目录: `mkdir logs`
6. 创建数据库:`mv config.sample.py config.py && python rebuildDB.py`
7. 安装`redis`:建议先安装宝塔,然后直接用宝塔安装redis(ps.必须安装redis)
8. 网站目录下运行:`gunicorn -w4 -b 0.0.0.0:5000 run:app`

然后访问 ip:5000 试试
如果不能访问,看看防火墙是否开了5000端口?
Expand Down
3 changes: 2 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from flask_pagedown import PageDown
import logging
import datetime
from redis import Redis

# 日志记录
logger = logging.getLogger("ojbk")
Expand All @@ -18,10 +19,10 @@
ch.setFormatter(formatter)
logger.addHandler(ch)

rd = Redis(host='localhost', port=6379, db=0)

app = Flask(__name__)
app.config.from_object('config')

# Celery configuration
#celery = Celery(__name__, broker=app.config['CELERY_BROKER_URL'])
db = SQLAlchemy(app, use_native_unicode='utf8')
Expand Down
Binary file modified app/parser.pyc
Binary file not shown.
26 changes: 16 additions & 10 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from app import db
from app.models import Context
import parser
from . import logger
from . import logger,rd
from config import *
from captcha import *

Expand Down Expand Up @@ -71,16 +71,22 @@ def getmd5():


def getipwhois(ip):
url='http://tool.chinaz.com/ipwhois?q={}'.format(ip)
try:
r=requests.get(url,headers=headers,timeout=8)
if rd.exists(ip) and rd.get(ip)!='home':
netname=rd.get(ip)
print '{} exists in redis,netname {}'.format(ip,netname)
else:
print '{} exists doesn\' exists in redis'.format(ip)
url='http://tool.chinaz.com/ipwhois?q={}'.format(ip)
try:
netname=re.findall('netname:(.*?)<br/>',r.content)[0].replace(' ','')
except:
netname=re.findall('<p>Name : (.*?)</p>',r.content)[0].replace(' ','')
except Exception,e:
print e
netname='home'
r=requests.get(url,headers=headers,timeout=8)
try:
netname=re.findall('netname:(.*?)<br/>',r.content)[0].replace(' ','')
except:
netname=re.findall('<p>Name : (.*?)</p>',r.content)[0].replace(' ','')
rd.set(ip,netname)
except Exception,e:
print e
netname='home'
return netname


Expand Down
4 changes: 2 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
basedir=os.path.abspath(os.path.dirname(__file__))

SECRET_KEY='SSDFDSFDFD'
#SQLALCHEMY_DATABASE_URI='mysql+pymysql://user:passwd@localhost/db'
SQLALCHEMY_DATABASE_URI='sqlite:///'+os.path.join(basedir,'data.sqlite')
SQLALCHEMY_DATABASE_URI='mysql+pymysql://jx:cyx210210@localhost/jx'
#SQLALCHEMY_DATABASE_URI='sqlite:///'+os.path.join(basedir,'data.sqlite')
SQLALCHEMY_TRACK_MODIFICATIONS=True
debug=True
domain='http://ojbk.us'
Expand Down
13 changes: 13 additions & 0 deletions config.sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
basedir=os.path.abspath(os.path.dirname(__file__))

SECRET_KEY='SSDFDSFDFD'
#SQLALCHEMY_DATABASE_URI='mysql+pymysql://user:passwd@localhost/db'
SQLALCHEMY_DATABASE_URI='sqlite:///'+os.path.join(basedir,'data.sqlite')
SQLALCHEMY_TRACK_MODIFICATIONS=True
debug=True
domain='http://ojbk.us'
mm2='http://v.33k.im'
porn91='http://91porn.com'
#CELERY_BROKER_URL = 'redis://localhost:6379/0'
#CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'

0 comments on commit 3b68717

Please sign in to comment.