Devlog #2 | Yummy cookies
Recap!!
Fero is an application that runs locally on your computer allowing you to transfer files to and from your devices. Last devlog I explained that I managed to setup a sort of session system to assign devices a “room”, that will be useful for the transfer of files later on, but then I realised that flask can not really manage sessions server side…
What’s new?
I managed to find out how to make titles and stuff for my devlogs :). But yeah, you’re probably wondering what’s new for Fero and not my devlog :(.
After some time of research, I realised I would not use flask-session, it wasn’t documented very well in my opinion, so it was difficult trying to implement it. I knew I needed some sort of database like SQL, and I knew how to use SQL a bit because of this super awesome steam game that teaches you about SQL (shout out Database Detective!!!). After a quick search I found flask_sqlalchemy, it gives you the ability to host your database in a file ending with .db and doesn’t require you to setup a service running in a different port and in docker (yeah flask-session I’m looking at you. Who even uses redis???). After some trial and error, I got the hang of the package, and I managed to implement a Rooms database that grabs the room’s ID, device IP (which is set as unique and the primary key), invite code, and the device type (whether the device is recieving or sending):
class Rooms(db.Model):
roomident: Mapped[str]
deviceip: Mapped[str] = mapped_column(unique=True, primary_key=True)
invcode: Mapped[str]
devicetype: Mapped[str]
I’ve added the ability to delete rooms, get room info of the receiver or the sender, delete client sessions, and made the room info show a QR code that allows you to join the room from a different device!
@app.route('/reciever/join/<joincode>')
def bindingjoin(joincode):
findRoom = db.session.execute(db.select(Rooms.roomident).where(Rooms.invcode == joincode)).scalar_one()
# took me a RIDICULOUS amount of time to figure out how to filter it, turns out I was doing Rooms.roomident == joincode instead of Rooms.invcode == joincode. smh.
session['ident'] = findRoom
session['joincode'] = joincode
session['IP'] = request.remote_addr
session['type'] = "recieve"
createdroom = Rooms(roomident=findRoom, invcode=joincode, deviceip=request.remote_addr, devicetype="recieve")
db.session.add(createdroom) db.session.commit()
return redirect('http://' + IPAddr + ':5000/reciever/roominfo')
I’ve also added temporary developer tools in order to debug my program, this WILL be removed in the future as they provide access to modifications and the invite code (big no no to leave it public) to EVERY client. Unless I can find a way to leave it in WITHOUT giving access to it to every client.
This took me a lot of time to make, mostly because I was experimenting with a new package that I have no clue how to use. I don’t remember really what were the parts that were super hard to implement because this devlog was supposed to be upload like 2 days ago, but I took a little well-deserved break.
What’s next?
Now we have a way to track devices (local router assigned IP and room Ident) and what they are supposed to be doing (recieving or sending), I will implement a new system that allows me to get ADDITIONAL device information (like device name), that way in the future, we can approve or deny access to clients to the room. I will also now work on the MAIN part of the project now, which is file sending and recieving. Which will be an IMPORTANT milestone and I cannot wait!
What’s attached?
Just some photos of some of the dev tools and the new room info page.