import pprint import queue import config from common.mongodb.mongodb import conn_mongodb, select_database, select_collection, insert_many from common.task.task import TaskQueue from spider import spider from web import web mongodb = conn_mongodb(config.mongodb_host, config.mongodb_port) db = select_database(mongodb, config.mongodb_database) users_collection = select_collection(db, config.mongodb_users_collection) relations_collection = select_collection(db, config.mongodb_relations_collection) task_queue_collection = select_collection(db, config.mongodb_task_queue_collection) TaskQueue.init(task_queue_collection) dict_collections = { 'users': users_collection, 'relations': relations_collection, 'task_queue': task_queue_collection, } spider.run(config.spider_thread_num, TaskQueue, dict_collections) web.run(config.web_server_port)
# catajudge=re.search(r'[^/]*$',urlpath).group(0) # if urlpath.endswith("GBS"): # path='../../toDownload/classical_paper/GBS/' # elif urlpath.endswith("Python_study"): # path='../../toDownload/pythonstudy/' # elif urlpath.endswith(".html"): # print("sssss") # return static_file(urlpath,root='../../index') # else: # print(unquote(urlpath)) # path = "../../"+re.search(r'catalog/(.*)',unquote(urlpath)).group(1)+"/" # print(path) # else:#download file # path="../../"+re.search(r'^.*/',unquote(urlpath)).group(0) # print(urlpath,re.search(r'^.*/',urlpath).group(0),re.search(r'[^/]*$',urlpath).group(0)) # return static_file(re.search(r'[^/]*$',urlpath).group(0), root='../../classical_paper/'+re.search(r'^.*/',urlpath).group(0),download=re.search(r'[^/]*$',urlpath).group(0)) # l=os.listdir(path=path) # print(l,path) # for a in l: # if os.path.isdir(path+a) and not urlpath.endswith("rar"): # url=quote('/download/catalog/'+re.search(r'\.\./\.\./(.*)',path+a).group(1)) # herfs+="""<a href="""+url+""" target="_self">"""+a+"""</a></p> # """ # elif os.path.isfile(path+a): # url=quote('/downloadfile/'+re.search(r'\.\./\.\./(.*)',path+a).group(1)) # herfs+="""<a href="""+url+""" target="_self">"""+a+"""</a></p> # """ # return herfs if __name__ == '__main__': web.run(host="localhost",port=8080,debug = True)
from web import web if __name__ == '__main__': web.run(host='0.0.0.0', port=5000, debug=True)
from bot import bot from captcha import creator from db import models from web import web if __name__ == '__main__': creator.setup() models.setup() web.run() bot.run()
''' Created on 2018-3-19 @author: Dr.liu ''' from web import web from web import views import socket def get_host_ip(): try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('8.8.8.8', 80)) ip = s.getsockname()[0] finally: s.close() return ip if __name__ == '__main__': web.run(host=get_host_ip(), port=8314, debug=True)
import threading from web import web web.run(port=5000, host='0.0.0.0', debug=True)
import api_keys from web import web web.run(api_keys)
# -*- coding: utf-8 -*- from web import web web.run(debug=True)