forked from hobbee/MachineLearningAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
50 lines (44 loc) · 1.19 KB
/
Copy pathindex.py
File metadata and controls
50 lines (44 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
import cherrypy
import json
from controllers.automatic_tag import automatic_tag as auto_tag
from controllers.association import association as association
import glob
import os.path
import codecs
import re
'''
def find_all():
for file in glob.glob('./models/resources/articles/*'):
id = re.compile("[0-9]+").search(file).group(0)
allLines = open(file, 'r', encoding='utf-8').read()
yield (id, allLines)
'''
import sys
sys.path.append("./models/")
import model as Model
from model import model
from article import article
if __name__ == '__main__':
Model.Base.metadata.create_all(Model.Engine)
cherrypy.config.update({'server.socket_host': '0.0.0.0'
})
cherrypy.tree.mount(
auto_tag(), '/api/auto_tag',
{'/':
{'request.dispatch': cherrypy.dispatch.MethodDispatcher()}
}
)
cherrypy.tree.mount(
association(), '/api/association',
{'/':
{'request.dispatch': cherrypy.dispatch.MethodDispatcher()}
}
)
cherrypy.engine.start()
cherrypy.engine.block()
'''
for item in find_all():
article = articles(item[1])
article.save()
'''