# Connect to the database. conn = sqlite3.connect(config["paths"]["file_auth_database"]) c = conn.cursor() # Save new user in the database. c.execute("INSERT INTO `secure_login`(`ID`,`Username`,`Password`) VALUES (?,?,?)", (None, new_username, hash)) conn.commit() c.close() # Redirect. response.status = 303 response.set_header('Location', '/users') else: # Redirect. response.status = 303 response.set_header('Location', '/users') """ # Part 4: Send to daemon - No the above code will be launched in the daemon script located in the /lib directory. """ # This is a fix for the view directory. TEMPLATE_PATH.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "view"))) # Pass this code to the lib.bottledaemon so the server can start. from lib.bottledaemon import daemon_run if __name__ == "__main__": daemon_run()
__author__ = 'reason' from lib.bottle import Bottle,TEMPLATE_PATH import index,shunion,option ,datareport ,nokiareport,ssx,wlapi,tdwap import setting TEMPLATE_PATH.insert(0,setting.TEM_PATH) app=Bottle() app.mount("/nokiadata",nokiareport.app) app.mount("/data",datareport.app) app.mount("/index",index.app) app.mount("/shunion",shunion.app) app.mount("/option",option.app) app.mount("/ssx",ssx.app) app.mount("/wlapi",wlapi.app) app.mount("/tdwap",tdwap.app)
days_in_advance = 3 events = {} now = datetime.datetime.utcnow() for d in range(days_in_advance): tm = now + datetime.timedelta(days=d) events[tm.strftime("%A")] = get_event_for_day(tm.date()) return events def get_news(): d = feedparser.parse(NEWS_FEED) return d['entries'] tpl_path = os.path.join(get_script_rel_path("templates")) TEMPLATE_PATH.insert(0, tpl_path) if __name__ == '__main__': parser = argparse.ArgumentParser(description='starts a lists server') parser.add_argument( '--config', help='specifies the config file location (default: ./config.json)', default="./config.json") args = parser.parse_args() with open(args.config) as f: config = json.load(f) run(host='0.0.0.0', port=config['port'], reloader=True) app = default_app()