The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

0

I'd really made GET and POST routes into separate functions. Makes your project clearer as it grows. Instead of error +=, I'd made errors a list, and appended to that. It may be not an obvious win in your case, but imagine you will want some other way to separate errors in the future, eg, with HTML. Also it would be much simpler, if postable could serve as ...


0

Your code looks okay to me. For your questions: Flask uses Jinja template engine, it already does XSS filter automatically for you. So you don't need to worry about that. Actually, implementing a XSS filter has a lot of things to concern, so just leave it to the template engine. For a toy app, storing data into a json file is fine. But in actual production ...


3

Date formatting self.date_created = f"{now.month}/{now.day}/{now.year} {now.hour}:{now.minute}:{now.second} {end}" should be from datetime import datetime ... datetime.now().strftime('%m/%d/%Y %I:%M:%S %p') Generators for logic for word in self.content.split(): if word.lower() in ["phooey", "shucks", "rascal"]: return True ...


Top 50 recent answers are included