bot upgrade 1

This commit is contained in:
Andreas Stephanides
2017-01-14 14:22:17 +01:00
parent df6bff033a
commit 96cc97a13f
6 changed files with 91 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ import mworker
from compiler import do_compile
from fetching import fetch_page
from .controller import urls_test, start_workers, urls_que
#flask.json.JSONEncoder.default = lambda self,obj: ((obj.__json__()) if isinstance(obj, (Article,CrawlUrl)) else None)
@compiler_pages.route("/")
@@ -50,7 +50,7 @@ def initdb_json2():
@compiler_pages.route("/start")
@compiler_pages.route("/start.json")
def start_json():
mworker.start_workers(1,1,1) # initialisiere Datenbank
start_workers() # initialisiere Datenbank
status="Worker gestartet"
return jsonify(status=status)
@@ -76,24 +76,18 @@ def urls_json(id):
@compiler_pages.route("/urls/<int:id>/que.json")
def urls_que_json(id):
# Lade Alle Urls
cu=CrawlUrl.query.get(id)
mworker.queue_url(cu.tpe, cu.url)
cu=urls_que(id)
cc=CrawlCache.query.filter(CrawlCache.url==cu.url)
mworker.start_workers(1,1,1) # initialisiere Datenbank
status="Worker gestartet"
return jsonify(urls=cu, cache=cc)
# que an existing CrawlUrl for fetching
@compiler_pages.route("/urls/<int:id>/test")
@compiler_pages.route("/urls/<int:id>/test.json")
def urls_test_json(id):
# Lade Alle Urls
cu=CrawlUrl.query.get(id)
rw=fetch_page(cu.url)
h= {"url": cu.url, "sourcetype": cu.tpe, "raw": rw}
h2=do_compile(cu.tpe, h)
return jsonify(urls=cu,hs=h2,rw=rw)
return jsonify(result=urls_test(id))