daily log

2 minute read

THINGS I DID TODAY AM:

  • Spent the morning debugging A TYPO – 'Broswer Journal' vs 'Browser Journal'

I once had a boyfriend who noticed I dropped things all the time. He pointed this out to me with the oddly astute observation that I’ve started on the next thing before I’ve successfully completed grabbing/securing ‘the thing’

I feel like most of my life is like this. I’ve moved on to the next thing, relegating TASK A (grabbing the object) to a hind-brain process while I move TASK B into the forground. His point was that I was starting on TASK B before I’d really completed TASK A, or completed it enough to appropriately delegate it to the less advanced hind-brain (like I’m doing right now with this writing)

THINGS I DID TODAY PM:

  • Made a big mess this morning
  • Brainstormed on my drive home how I would solve my “passing to many hands” problem (aka I’m trying to do too many things at once problem)
  • Decided step one would be to write everything out
  • As you can see below, I did this.
  • As you can also see below, I iterated
  • Unfortunately, the big one wasn’t working so I decided I needed to take a step back and
  • SIMPLIFY
  • BREAK !! THAT !! PROBLEM !! DOWN !!
  • So my simplified version is just – uploading a file and that file hits /simple_uploader on my server – running a function that spawns a child python process when that route /simple_uploader is hit

in my app.js file on my node-running-express-on-aws-server

app.use('/simple_uploader', function(req, res) {
  // console.log('REQ', req)
  // res.json(req.body)

  const spawn = require("child_process").spawn;
  const pythonProcess = spawn('python',["./controllers/get_num_kitties.py", "salmon", "cheese"]);
  pythonProcess.stdout.on('data', (data) => {
    // toString() is V important lol!!
    console.log('data from appjs', data.toString())
  });
})
  • and then if you’re like wtf is the python script get_num_kitties doing (and why tf is in in a controller file bc I don’t know) ```python import random import sys

def get_data(): d1 = random.sample(range(1, 100), 3) d2 = sys.argv[1] data = [d1, d2] print(data) sys.stdout.flush() get_data()

AND OH EM GEE PRAISE BE THIS IS WORKING
See? We're getting what we're passing which was our goal!
Now we just have to pass the actual file!

```console
Application listening on port 4000!!! WHEE!! CATS 4 LYFE!!
data from appjs [[19, 67, 91], 'salmon']

REFERENCES:

Python sends a GET request to the Node server to retrieve the data. – In this case it is the JSON object {“data1”:”mee”, “data2”:”po”}

Once you process that data and do something with it, you can immediately send back a POST request to the Node server containing the data you want to send to the server. – Here it is the JSON object {“foo”: “bar”, “kaa”:”pa”}

The Node server will receive this object, use body-parser to parse it, process the parsed data, and send back a response of “process complete” to the Python file.

One of the most helpful walk-throughs I’ve found

Updated: