#!/usr/bin/env python3 # -*- coding:utf-8 -*- from lib.bottle import Bottle from lib.bottle import TEMPLATE_PATH from lib.bottle import jinja2_template from lib.bottle import request from sample.models.data import website app = Bottle() TEMPLATE_PATH.append('../sample/views') @app.route('/', method=["GET", "POST"]) def index(): add_website_page = "add_website.html" login_page = "login.html" session = request.environ.get('beaker.session') user_id = session.get("user_id", "") # セッション情報が残っていた場合 if user_id: cls_website = website.Website() attention = u"" website_name = request.forms.decode().get('website_name', "") website_link = request.forms.decode().get('website_link', "") website_keywords = request.forms.decode().get('website_keywords', "") complete_add_website = request.forms.get('complete_add_website', "False") if website_link: if not website_name: website_name = cls_website.get_website_title_with_link(website_link)
#!bin/python3 # coding=utf8 from lib.bottle import run, view, template, request, response, route, post, get, static_file, TEMPLATE_PATH, debug from lib import mylib, config from poster import Poster ################################################# debug(True) TEMPLATE_PATH.append('./template') exception_format = ' <span style="color: red">%s :(</span>' config = config.Config('config.cfg') # 格式: posters = {username: Poster} #test_poster = Poster( #{'username': '******', 'password': '******'}, #config.get_section('global')['global'], #config.get_section('user_section1')['user_section1'] #) #posters = {'test': test_poster} posters = {} auths = {} is_action = False ################################################# def get_form_dict(form, is_user_section=False): """ is_user_seciton 参数, 是为了处理 checkbox 和 radiobox 不选中时不传值过来的情况 """ temp = {} if is_user_section: temp = { 'is_random': '0', 'is_repeat': '0' } for key in form: