コード例 #1
0
    def post(self):
        self.set_header('Access-Control-Allow-Origin', '*')
        self.set_header('Access-Control-Allow-Methods',
                        'POST, GET, HEAD, OPTIONS')
        self.set_header('Access-Control-Allow-Headers', 'X-Requested-With')

        user = self.get_user_from_subdomain()
        request_dict = json.loads(self.request.body)
        if not self.validate_input(["page_html", "uri"], request_dict):
            return

        if user == None:
            self.throw_404()
            return

        page = CollectedPage()
        page.uri = request_dict.get("uri")
        page.page_html = request_dict.get("page_html")
        page.owner_id = user.id
        page.timestamp = int(time.time())

        self.logit("Received a collected page for user " + user.username +
                   " with a URI of " + page.uri)

        session.add(page)
        session.commit()
コード例 #2
0
    def post(self, req):
        user = self.get_user_from_subdomain()
        if user is None:
            self.throw_404()
            return
        page = CollectedPage()
        page.uri = req.get("uri", "")
        page.page_html = req.get("page_html", "")
        user.collected_pages.append(page)

        self.logit("Received a collected page for user " + user.username +
                   " with a URI of " + page.uri)
        self.db_session.add(page)
        self.db_session.add(user)
        self.db_session.commit()
コード例 #3
0
ファイル: apiserver.py プロジェクト: ajaska/xsshunter
    def post( self ):
        self.set_header( 'Access-Control-Allow-Origin', '*' )
        self.set_header( 'Access-Control-Allow-Methods', 'POST, GET, HEAD, OPTIONS' )
        self.set_header( 'Access-Control-Allow-Headers', 'X-Requested-With' )

        user = self.get_user_from_subdomain()
        request_dict = json.loads( self.request.body )
        if not self.validate_input( ["page_html", "uri"], request_dict ):
            return

        if user == None:
            self.throw_404()
            return

        page = CollectedPage()
        page.uri = request_dict.get( "uri" )
        page.page_html = request_dict.get( "page_html" )
        page.owner_id = user.id
        page.timestamp = int(time.time())

        self.logit( "Received a collected page for user " + user.username + " with a URI of " + page.uri )

        session.add( page )
        session.commit()