def del_repo(): if request.method == 'DELETE': repo = request.args.get('repo', None) if repo: desc = REDIS.hget('repos', repo) desc = json.loads(desc) desc.update(is_show='0') REDIS.hset('repos', repo, json.dumps(desc)) return jsonify({"status": True})
def search_github(keyword): # 爬取 20 页最新的列表 for i in range(1, 20): res = requests.get(SEARCH_API % (keyword, i)) repo_list = res.json()['items'] for repo in repo_list: repo_name = repo['html_url'] desc = { 'repo_desc': repo['description'], 'star': repo['stargazers_count'], 'is_show': REPO_SHOW } REDIS.hset('repos', repo_name, json.dumps(desc)) print(repo_name) time.sleep(10)
def add_todo(): if request.method == 'POST': if request.form['id'] != '': todo = {} todo_id = request.form['id'] todo['title'] = request.form['title'] todo['descript'] = request.form['descript'] todo['create'] = datetime.datetime.today().strftime('%Y/%m/%d %H:%M:%S') todo['due'] = request.form['due'] todo['status'] = request.form['status'] REDIS.hset('todolist',todo_id,json.dumps(todo)) return redirect(url_for('index'))