Closed ryansurf closed 6 months ago
@ryansurf Hai! I noticed you changed the backend to Flask. I think that's a good move!
Since you switched to Flask, you can return index.html
as a template engine.
By using a template engine, you can pass environment variables to script.js
via HTML.
I'll take care of this:)
@K-dash Hello! httpserver was being a pain, Flask is much better haha
I was messing with a few things last night, and decided to pass the variables in from the config.json
file, not the .env
anymore. Flask servers the config.json, which is where script.js
now accesses those variables(see the first 25 lines of script.js.
What do you think, is that the right move? Or is your idea the more elegant solution?
@ryansurf Yeah, I was also thinking that httpserver needed improvement (lol)
I was messing with a few things last night, and decided to pass the variables in from the config.json file, not the .env anymore. Flask servers the config.json, which is where script.js now accesses those variables(see the first 25 lines of script.js.
I took a look at your implementation! However, I believe my implementation is more appropriate because it's simpler, requires less code, and follows Flask's usage conventions. Also, having both config.json and .env files for managing environment variables felt a bit odd to me, so I thought about unifying them into .env. I've submitted a PR, so please review it!
Good points, seems like that's the move then. I'll take a look/approve your PR when I get home later today😎
Good work! Seems like you know what you're doing haha
The top lines of
src/frontend/script.js
has:const ipAddress = 'localhost';
andconst port = 8000;
. I think it would be best to store these variables in the.env
file in the root of the projectWe should be able to load in the variables from the
.env
file in our JavaScript, like:const ipAddress = env.IPADDRESS
, or however you would do that.