Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Muxxs authored Feb 6, 2020
1 parent 6316eef commit ec3f458
Show file tree
Hide file tree
Showing 9 changed files with 354 additions and 0 deletions.
20 changes: 20 additions & 0 deletions wuhan2020_api-master/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# wuhan2020_api
wuhan2020数据库 API接口


基于Flask
提交json格式:

```
data = {
'province': "",
'city': '0',
'publish_time': '00:00:00',
'publish_date': 0,
'title': 0,
'content': 0,
'link': 0,
'links_to_pic': 0,
'announce_type': 0
}
```
11 changes: 11 additions & 0 deletions wuhan2020_api-master/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#coding=utf-8
from flask import Flask,request
from control import readCtl, writeCtl

app: Flask = Flask(__name__)
app.register_blueprint(readCtl)
app.register_blueprint(writeCtl)

if __name__ == '__main__':
app.run()

4 changes: 4 additions & 0 deletions wuhan2020_api-master/control/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .read import read as readCtl
from .write import write as writeCtl

__all__ = {"readCtl", "writeCtl"}
10 changes: 10 additions & 0 deletions wuhan2020_api-master/control/read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#coding=utf-8
from flask import Blueprint

read = Blueprint('read', __name__)

@read.route("/api/read", methods=['GET'])
def index():
return "read"


12 changes: 12 additions & 0 deletions wuhan2020_api-master/control/write.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#coding=utf-8
from flask import Blueprint, request, json, jsonify
from model.type import FailResp,SuccessResp, createArchive
from sql.insert import insert

write = Blueprint('write', __name__)

@write.route('/api/write', methods=['POST'])
def index():
data = json.loads(request.data)
insert(createArchive(data))
return jsonify(SuccessResp())
49 changes: 49 additions & 0 deletions wuhan2020_api-master/model/type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

class Archive:
def __init__(self):
self.province = ""
self.city = '0',
self.publish_time = '00:00:00',
self.publish_date = "0000-00-00",
self.title = ""
self.content = "",
self.link = "",
self.links_to_pic = "",
self.announce_type = 0

def toDict(self) -> dict:
return {
"province": self.province,
"publish_time": self.publish_time,
"publish_date": self.publish_date,
"title": self.title,
"content": self.content,
"link": self.link,
"links_to_pic": self.links_to_pic ,
"announce_type": self.announce_type,
}

class Response:
def __init__(self, code = 0, msg = "", data=None):
self.code = code
self.message = msg
self.data = data


def FailResp():
return Response(code=-1, msg="发生错误")

def SuccessResp(data):
return Response(code=0, msg="成功", data=data)

def createArchive(data:dict)->Archive:
result = Archive()
result.province = data.get("province", "")
result.publish_time = data.get("publish_time",'00:00:00')
result.publish_date = data.get("publish_date", "0000-00-00")
result.title = data.get("title", "")
result.content = data.get("content", "")
result.link = data.get("link", "")
result.links_to_pic = data.get("links_to_pic", "")
result.announce_type = data.get("announce_type", "")
return result
220 changes: 220 additions & 0 deletions wuhan2020_api-master/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
absl-py==0.8.1
appdirs==1.4.3
appnope==0.1.0
asn1crypto==0.24.0
astor==0.8.0
astroid==2.3.3
astropy==3.2.3
atomicwrites==1.3.0
attrs==19.1.0
backcall==0.1.0
baidu-aip==2.2.17.0
bcrypt==3.1.7
beautifulsoup4==4.8.0
bleach==3.1.0
bosonnlp==0.11.0
bs4==0.0.1
cachetools==3.1.1
capstone==4.0.1
censys==0.0.8
certifi==2018.1.18
cffi==1.12.3
chardet==3.0.4
chart-studio==1.0.0
Click==7.0
click-plugins==1.1.1
colorama==0.4.1
confuse==1.0.0
cryptography==2.7
cycler==0.10.0
decorator==4.4.0
defusedxml==0.6.0
dnslib==0.9.10
dnspython==1.16.0
docopt==0.6.2
docutils==0.15.2
ecdsa==0.13.2
entrypoints==0.3
Faker==3.0.0
filelock==3.0.12
Flask==1.1.1
foolbox==1.8.0
funcsigs==1.0.2
future==0.17.1
gast==0.2.2
gevent==1.4.0
gitdb2==2.0.5
GitPython==3.0.2
google-auth==1.7.0
google-auth-oauthlib==0.4.1
google-pasta==0.1.8
graphviz==0.5.1
greenlet==0.4.15
grequests==0.4.0
grpcio==1.25.0
h5py==2.10.0
htmlmin==0.1.12
idna==2.6
imageio==2.5.0
imageio-ffmpeg==0.3.0
importlib-metadata==0.19
intervaltree==2.1.0
ipykernel==5.1.3
ipython==7.9.0
ipython-genutils==0.2.0
isort==4.3.21
itchat==1.2.32
itsdangerous==1.1.0
jedi==0.15.1
jieba==0.39
Jinja2==2.10.1
joblib==0.13.2
jsmin==2.2.2
json5==0.8.5
jsonschema==3.2.0
jupyter-client==5.3.4
jupyter-core==4.6.1
jupyterlab==1.2.3
jupyterlab-server==1.0.6
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
Kivy==1.11.1
Kivy-Garden==0.1.4
kiwisolver==1.0.1
lazy-object-proxy==1.4.3
llvmlite==0.30.0
lxml==3.8.0
Mako==1.1.0
Markdown==3.1.1
MarkupSafe==1.1.1
matplotlib==2.2.2
mccabe==0.6.1
missingno==0.4.2
mistune==0.8.4
mock==3.0.5
more-itertools==7.2.0
moviepy==1.0.0
nbconvert==5.6.1
nbformat==4.4.0
netaddr==0.7.19
neupy==0.8.2
nltk==3.4.5
notebook==6.0.2
numba==0.46.0
numpy==1.17.3
oauthlib==3.1.0
objgraph==3.4.1
opencv-python==4.1.2.30
opt-einsum==3.1.0
packaging==19.1
paddlepaddle==1.6.1
pandas==0.25.3
pandas-profiling==2.3.0
pandocfilters==1.4.2
paramiko==2.6.0
parso==0.5.1
pep517==0.7.0
pexpect==4.7.0
phik==0.9.8
pickleshare==0.7.5
Pillow==5.0.0
pipreqs==0.4.9
plotly==4.1.0
pluggy==0.12.0
prettytable==0.7.2
proglog==0.1.9
progressbar2==3.34.3
prometheus-client==0.7.1
prompt-toolkit==2.0.10
protobuf==3.10.0
psutil==5.6.3
ptyprocess==0.6.0
pwntools==3.12.2
py==1.8.0
pyasn1==0.4.7
pyasn1-modules==0.2.7
PyAudio==0.2.11
pycparser==2.19
pycurl==7.43.0.3
pyelftools==0.25
PyFME==0.2.dev0
pygame==1.9.3
Pygments==2.4.2
pylint==2.4.4
PyNaCl==1.3.0
pypandoc==1.4
pyparsing==2.2.0
pypinyin==0.35.4
pypng==0.0.20
PyQRCode==1.2.1
pyrsistent==0.15.6
pyserial==3.4
PySocks==1.7.1
pyte==0.8.0
pytesseract==0.3.0
pytest==5.0.1
pytest-pylint==0.14.1
python-dateutil==2.7.2
python-for-android==2019.8.9
python-utils==2.3.0
pytoml==0.1.21
pytz==2018.4
PyYAML==5.1.2
pyzmq==18.1.1
qrcode==6.1
rarfile==3.1
requests==2.22.0
requests-oauthlib==1.3.0
retrying==1.3.3
ROPGadget==5.8
rsa==4.0
scikit-learn==0.21.3
scipy==1.3.0
seaborn==0.9.0
selenium==3.11.0
Send2Trash==1.5.0
sh==1.12.14
shodan==1.14.0
six==1.11.0
sklearn==0.0
smmap2==2.0.5
sortedcontainers==1.5.10
soupsieve==1.9.3
tensorboard==1.13.1
tensorflow==1.13.2
tensorflow-estimator==1.13.0
termcolor==1.1.0
terminado==0.8.3
testpath==0.4.4
text-unidecode==1.3
texttable==1.6.2
thefuck==3.29
threadpool==1.3.2
toml==0.10.0
tornado==6.0.3
tox==3.14.0
tqdm==4.36.1
traitlets==4.3.3
tushare==1.2.48
typed-ast==1.4.0
unicorn==1.0.1
urllib3==1.22
uuid==1.30
virtualenv==16.7.5
wcwidth==0.1.7
web.py==0.33
webencodings==0.5.1
webrtcvad==2.0.10
Werkzeug==0.15.5
wfuzz==2.4
wrapt==1.11.2
wxpy==0.3.9.8
xlrd==1.2.0
XlsxWriter==1.2.0
xmltodict==0.12.0
yagmail==0.11.220
yarg==0.1.9
you-get==0.4.1355
zhihu==0.2.6
zhihu-oauth==0.0.41
zipp==0.6.0
13 changes: 13 additions & 0 deletions wuhan2020_api-master/sql/conn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pymysql.cursors

# Connect to the database

def connect()->pymysql.Connection:
return pymysql.connect(
host='localhost',
user='user',
password='passwd',
db='db',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor
)
15 changes: 15 additions & 0 deletions wuhan2020_api-master/sql/insert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .conn import connect
from model.type import Archive

connection = connect()


def insert(data: Archive):
with connection.cursor() as cursor:
# Create a new record
sql = "INSERT INTO `archive` \
(`province`,`city`,`publish_time`,`publish_date`,`title`,`content`,`link`,`links_to_pic`,`announce_type`) \
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)"

cursor.execute(sql, (data.province, data.city, data.publish_time, data.publish_date, data.title, data.content, data.link,data.links_to_pic,data.announce_type))
connection.commit()

0 comments on commit ec3f458

Please sign in to comment.