def post(self): BaseHandler.initialize(self) self.title = "Rating" ext = self.get_cookie('ext') appealRating = self.get_argument('appeal', default=4) #complexityRating = self.get_argument('complexity', default=4) wid = self.get_argument('wid', default='') print(wid) if wid == '999': self.redirect('/layout/note?trial=0') else: title = self.get_argument('title', default='anonymous') uid = self.get_cookie('uid') name = self.get_secure_cookie('username').decode("utf-8") print(uid) newWebpage = Webpage(wid, ext, title, name) newWebpage.appeal = int(appealRating) #newWebpage.complexity = int(complexityRating) newWebpage.write2CSV() m = self.get_cookie('m') if m == '': self.redirect("/layout/finish") else: try: g = n_cookie.match(m) wid, title = settingslay.WebpageList[int(g.group(1))].split('*') except Exception as e: print(e) ErrorHandler.write_error(500) self.redirect("/layout/start/"+ str(wid))
def get(self, wid): BaseHandler.initialize(self) self.title = "Start" fixation_path = "images/fixation.png" noise_path = "images/noise.png" if wid == '999': webpage_path = "images/webpages/ted.com.png" self.render("experiment/aesthetics/webpage.html", fixation_path=fixation_path, webpage_path=webpage_path, noise_path=noise_path, title='ted.com', wid=wid) wid2, title = WebpageList[int(wid)].split('*') webpage_path = "images/webpages/" + title + ".png" n = self.get_cookie('n') print(n) g = n_cookie.match(n) print(g.group(2)) self.set_cookie('n', g.group(2)) self.render("experiment/aesthetics/webpage.html", fixation_path=fixation_path, webpage_path=webpage_path, noise_path=noise_path, title=title, wid=wid2)
def get(self): BaseHandler.initialize(self) self.title = "Thank you so much ~" Name = self.get_secure_cookie('username') self.clear_cookie('username') self.clear_cookie('uid') self.clear_cookie('n') self.render("main/finish.html", slogan=Name)
def get(self): BaseHandler.initialize(self) n = list(range(len(WebpageList))) random.shuffle(n) n = str(reduce(lambda x, y: x+y, list(map(lambda x: str(x) + "-", n)))) print(n) self.set_cookie('n', n) self.title = 'Home' self.render("experiment/main.html")
def get(self): BaseHandler.initialize(self) trial = self.get_argument("trial", default=0) self.title = "Note" n = self.get_cookie('n') g = n_cookie.match(n) if trial == '1': self.render("experiment/aesthetics/second.html", wid=999) if trial == '0': wid, title = WebpageList[int(g.group(1))].split('*') self.render("experiment/aesthetics/second.html", wid=wid)
def get(self): BaseHandler.initialize(self) trial = self.get_argument("trial", default=0) self.title = "Note" m = self.get_cookie('m') g = n_cookie.match(m) if trial == '1': self.render("experiment/layout/second.html", wid=999) if trial == '0': wid, title = settingslay.WebpageList[int(g.group(1))].split('*') self.render("experiment/layout/second.html", wid=wid)
def get(self): BaseHandler.initialize(self) ext = self.get_argument("ext") m = list(range(len(settingslay.WebpageList))) random.shuffle(m) m = str(reduce(lambda x, y: x+y, list(map(lambda x: str(x) + "-", m)))) print(m) self.set_cookie('m', m) self.set_cookie('ext', ext) self.title = "Statement" self.render("experiment/layout/first.html")
def get(self): pagetitle = self.get_argument("pagetitle") BaseHandler.initialize(self) appeal = webpageDict[pagetitle] self.title = 'Optimizing' self.render("visualization/vmain.html", pagetitle=pagetitle, appeal=int(appeal) + 2, location=[], mark='', originappeal=appeal, returned_ranking=returned_ranking)
def post(self): BaseHandler.initialize(self) pagetitle = self.get_argument("pagetitle") appeal = self.get_argument("appeal") originappeal = webpageDict[pagetitle] print(appeal) windowWidth = 1900 windowHeight = 900 + 123 self.title = "Optimizing" location, mark = homogeneityModel(pagetitle, float(appeal)) self.render("visualization/vmain.html", pagetitle = pagetitle, appeal = appeal, location = location, mark = mark, originappeal = originappeal, returned_ranking = returned_ranking)
def find_handler(): """ Returns: result: 收集到的各个handler的路由表 """ module_list = os.listdir("handlers") cls_require_imp = [] for module_item in module_list: try: module = importlib.import_module( f"handlers.{module_item.split('.')[0]}") for cls in filter(lambda x: x.endswith("Handler"), dir(module)): obj = getattr(module, cls) if cls == "BaseHandler": continue if issubclass(obj, BaseHandler): cls_require_imp.append(cls) else: continue except Exception: pass url_dict = BaseHandler.get_sub_cls() result = {} for k, v in url_dict.items(): result[k.lower()] = v return result
def __init__(self, bool_clf_dir=BOOL_CLF_DIR, type_clf_dir=TYPE_CLF_DIR): self.sio = socketio.AsyncServer() self.app = web.Application() self.sio.attach(self.app) self.sockets = [] bool_clf = self.get_latest_clf(BOOL_CLF_DIR) type_clf = self.get_latest_clf(TYPE_CLF_DIR) self.analyzer = Analyzer(pickled_bool_clf=bool_clf, pickled_type_clf=type_clf) # Setup database to store sessions. Load stored sessions. self.db = DBManager() # Setup Handlers base_handler = BaseHandler(self.analyzer, bool_clf_dir, type_clf_dir) self.app.router.add_get('/', handler=base_handler.index) self.app.router.add_post( '/bool-classifier', handler=base_handler.add_bool_classifier) self.app.router.add_post( '/type-classifier', handler=base_handler.add_type_classifier) # Setup Socket IO self.init_socketio()
def get(self, wid): BaseHandler.initialize(self) self.title = "Start" fixation_path = "images/fixation.png" noise_path = "images/noise.png" ext = self.get_cookie('ext') if wid == '999': webpage_path = "images/webpages/ted.com.png" self.render("experiment/layout/webpage.html", fixation_path = fixation_path, webpage_path = webpage_path, noise_path = noise_path, title = 'ted.com', wid = wid, ext=ext) wid2, title = settingslay.WebpageList[int(wid)].split('*') webpage_path = "images/webpages/" + title + ".png" m = self.get_cookie('m') print(m) g = n_cookie.match(m) print(g.group(2)) self.set_cookie('m', g.group(2)) self.render("experiment/layout/webpage.html", fixation_path = fixation_path, webpage_path = webpage_path, noise_path = noise_path, title = title, wid = wid2, ext=ext)
def post(self): BaseHandler.initialize(self) self.title = "Questionaire" ever = self.get_argument('ever', default='') email = self.get_argument('email', default='') name = self.get_argument('name', default='') gender = self.get_argument('gender', default='') age = self.get_argument('age', default='') country = self.get_argument('country', default='') edu = self.get_argument('edu', default='') design = self.get_argument('design', default='') newUser = User(ever, email, name, gender, age, country, edu, design) newUser.write2CSV() uid = newUser.id with open(os.path.join(os.path.dirname('./..'), "data/%s.csv") % name, "a+", newline='') as f: writer = csv.writer(f) writer.writerow(["id", "wid", "timestamp", "title", "appeal"]) self.set_cookie('uid', uid) self.set_secure_cookie('username', name) self.redirect('/aesthetic/note?trial=1')
def get(self): BaseHandler.initialize(self) self.title = "CHEC" self.render("home/home.html", title = self.title)
def get(self): BaseHandler.initialize(self) self.title = 'Optimizing Your Design' self.render("visualization/vhome.html")
def get(self): BaseHandler.initialize(self) self.write_error(404)
def initialize(self, *args, **kwargs): BaseHandler.initialize(self, *args, **kwargs) del kwargs['pool_executor'] BaseGQLHandler.initialize(self, *args, **kwargs)
def get(self): BaseHandler.initialize(self) self.title = "Statement" self.render("experiment/aesthetics/first.html")
def get(self): BaseHandler.initialize(self) self.title = "Questionaire" self.render("experiment/layout/form.html")