This is part four of my series on the Simmons LED Display. I'm going to describe the implementation of the web-based front end.
Here are some of the specs I wrote up for the web applic
ation:
- Users go to the Simmons LED website to enter messages.
- The Simmons LED website tells the user when their message will be displayed.
- The Simmons LED server displays the message at the given time for a fixed time (2 minutes).
- Only Simmons residents will be able to post messages.
- Messages will be profanity/obscenity/inappropriate filtered.
It's a pretty simple idea, the only non-straightforward aspect is some misdirection in the form of a database. The database allows for separation betw
een the display code and the web page code. Here's the flow of the program:
- A user visits the Simmons LED website.
- The user is allowed access if they are a Simmons resident.
- A message gets entered to the website.
- The website profanity filters the message.
- The website saves the message, with the current time, into the database.
- The website asks the database how many messages there are in line.
- The website tells the user when their message will be displayed.
- The display service repeatedly checks the database for new messages.
- The display service displays the oldest message for two minutes, then marks it as displayed.
The purpose of the database is to buffer the inputs, in case tons of users post messages all at once.
The Django code is shown below:
forms.py
models.py
views.py
Note: this code doesn't contain the profanity filter. I am planning on adding this as a validator in the message model.
The (very messy) html templates are coming soon.
No comments:
Post a Comment