Exemplo n.º 1
0
 def on_app_requested(self, app_id) -> str or int:
     db = DataStore(DataStore.get_db_connection(self._db_conn_str))
     app = db.get_app(app_id)
     if app:
         return json.dumps(app.json())
     else:
         return 404
Exemplo n.º 2
0
    def on_data_received(self, app_id: str, payload: str, accept_type: str, created: str = None) -> int:

        if created:
            try:
                created = float(created)
            except ValueError:
                return 400

        db = DataStore(DataStore.get_db_connection(self._db_conn_str))
        app_obj = db.get_app(app_id)
        entry_data = payload
        if not entry_data:
            return 400

        if not app_obj:
            db.create_app(app_id)

        # Either its binary or its text, we don't care for anything else when it comes to storage
        if accept_type == self._BINARY:
            return 501
        else:
            db.add_app_entry(app_id, entry_data, datetime.utcfromtimestamp(created) if created else created)
            return 200