python – Is my Flask social site endpoint cleanly written?

What I have here is a relatively simple endpoint for a small site I’m making. Idea is to take:

and create an entry in the database. It works properly.

I threw this together as something that should work and tried to make it clean (like with the error list that gets returned) but clearly I’m doing this all by hand. Are there best practices for writing these API-style endpoints that I’m not following?

I looked under the hood at a few sites (such as SO) and noticed they are using JSON as encoding for the response. That’s why I used it too.

On the input validation front, is my system decently robust or is it too flimsy?

I also tried to make the code safe by catching any exceptions that might pop up. If there’s something I’ve overlooked please let me know.

@main.route('/createpost', methods=('POST'))
def createpost():
resp = {
    'success': False

err = ()

u =  # 2458017363
title = request.values.get('title')
_tags = request.values.get('tags')  # JSON btw
content = request.values.get('content')
# _attachments = request.files.getlist('file')
# attachments = ()

# for f in _attachments:
#     if f.filename.rsplit('.', 1)(1).lower() not in ALLOWED_EXTENSIONS:
#         filepath = os.path.join(UPLOAD_DIR, secure_filename(f.filename))
#         attachments.append(filepath)
#     else:
#         err.append('File ' + f.filename + "is not permitted!")

if not title or len(title) > 100:
    err.append('Your title must exist and be less than 100 characters.')

    tags = json.loads(_tags)
    if not tags or len(tags) > 3:
        err.append('Choose between 1-3 tags so people know what your post is about!')
except Exception:
    err.append('Choose between 1-3 tags so people know what your post is about!')

if not content or len(content) < 50:
    err.append('Your content must be at least 50 characters.')

if err:
    resp('error') = err
    return Response(json.dumps(resp), mimetype='text/json')


while True:
        dbentry = Post(id=snowflake(),

    except IntegrityError:

resp('success') = True
return Response(json.dumps(resp), mimetype='text/json')

imports are as follows:

import json
import os

import bleach
from sqlalchemy.exc import IntegrityError

from .models import Post # sqlalchemy model for posts
from flask import Blueprint, render_template, request, Response
from flask_login import login_required, current_user
from werkzeug.utils import secure_filename

from . import db
from .utils import snowflake  # random number generator 
# (hence why i have a while loop around the db entry creation since there is a 
# miniscule chance it will give the same number again)

networking – Where is network data stored while awaiting to be written to disk?

I think download rates may depend on these 3 factors: the Network Infrastructure (router, VPN, network card, towers), the RAM or cache, the Final Storage (HDD or SDD or whatnot).

So we take this as an example: I have a very slow HDD Drive and very slow RAM but a very fast network adapter & router.

When downloading, for example, a Linux Live ISO, the adapter will download it fast but yet all content that is downloaded is not written to disk immediately.

So my plausible solutions would be:

  1. The Internet Stack (TCP/IP or whatever) allow clients to defer receiving network packets. So that a client could say to aserver directly: Yo, I’m still struggling with the data I received, would you mind sending me the next data after (when I tell you to do so).
  2. A software library pauses receiving data when struggling.
  3. Data is stored somewhere else (other than cache or RAM) (maybe on the router?)

Is there a one real answer or it depends?

blog – Is there a good open-source blogging system out there written in nodejs that comes with GUI?

I’ve been working with this company for a few years. When we first started, I wrote their website using PHP and their mobile app using Cordova. They needed a blogging system and so since we were using PHP as the language I hooked them with Serendipity. It’s old and it’s not that great but there was that one theme that looked modern enough to be usable. Serendipity is written in PHP and uses MySQL. What I like about it is that it offers a GUI backend for my client to be able to create and write posts on his own a bit like WordPress.

Thing is now we’re migrating to nodejs and postgres.

Here’s what I’m looking for :

  • Blog system with GUI for my client
  • Written in Nodejs
  • Open source
  • I’d like to be able to query every post my client writes from the blogging system and display/embedded them on the website. With Serendipity, it’s like a whole new website I have to link from their website.

I’ve done a bit of research and I came accross Poet which is written in node. But it doesn’t seem to offer any GUI for humans to be able to write, delete and create new posts?

Can anyone suggests anything? Thanks

dnd 5e – Is the Thirsting Blade eldritch invocation wrongly written?


Thirsting Blade

Prerequisite: 5th level, Pact o f the Blade feature

You can attack with your pact weapon twice, instead of
once, whenever you take the Attack action on your turn.”

So, by RAW: If it says “instead”, then otherwise (A.K.A. without that eldrich invocation) the rule would be: “You can attack with your pact weapon once whenever you take the Attack action on your turn.”

But the “original” rule is not this, you can’t “attack with you pact weapon once whenever you take the attack action”, actually, you can attack with your pact weapon once when you take the attack action AND choose to attack with your pact weapon. So, is that eldritch invocation wrongly written?

dnd 5e – What rules have been written for 5e D&D on Failing Forward?

I am looking for the rules in various 5e D&D books for allowing characters to add 1 or 2 points to their die-roll when they roll slightly too low. Searching Stack Exchange i found this, quoted from pg. 58 of the basic rules:

If the total equals or exceeds the DC, the ability check is a success—the creature overcomes the challenge at hand. Otherwise, it’s a failure, which means the character or monster makes no progress toward the objective or makes progress combined with a setback determined by the DM.

1. I could have sworn i found similar rules to the listed / above in the DMs guide years ago – cannot now. Sorry.

2. Unearthed Arcana may have new and brilliant quasi-rules on this. Cannot find it now.

3. Probably discussed already elsewhere on Stack Exchange. If so, please direct me there.

Where are the rules that allow a DM in 5e D&D to add a point or two on a failed d20 role (combat or not). Any rules. A tweet from His Royal Highness Crawford himself would be grand. It is also called ‘Success At A Cost’… perhaps.

Where in ~/.bitcoin are mempool and UTXO pools written?

Where in ~/.bitcoin are the two pools in question stored when their size grows above the size set by dbcache and maxmempool in bitcoin.conf.
Is UTXO pool written to such location at Bitcoin Core’s shutdown?

I will make your message or slogan written by sir Einstein for $3

I will make your message or slogan written by sir Einstein

Get sir Einstein write your message or slogan on blackboard and use it wherever you want and however you want.

Your message or slogan will become more impactful & effective if people see it is written by sir Einstein and they will follow your call to action fast.

6 reasons for your benefit :

  1. Fast Delivery
  2. High quality image
  3. Color image
  4. Less price, more images
  5. Available for conversation most of the time
  6. You can discuss with me before ordering

Thank You


i will provide attorney written credit repair letters for 2021 for $15

i will provide attorney written credit repair letters for 2021

Good day! Welcome and thank you for taking your time to visit my Gig.

These 10 powerful credit repair letters are all you need to dispute and win against both creditors and credit bureaus.

Attorney written with a 94% success rate.

You will get 10 attorney written credit repair Letters:

1. Step by step instructions and user guide

2. Collection agency dispute

3. Win against HIPPA using credit laws

4. Intent to file legal action

5. Goodwill letter

6. Credit Bureau Deletion letter

7. Remove hard inquires

8. Late payments

And much more

Place an order now and increase your credt score now.



Why is it so often written "myID" instead of "myId"

I very often see code containing the variable names "myID", while "ID" stands for "Identifier".

Why should it be ID?

The same goes for GUID/UUID, shouldn’t that be GUId/UUId?

For video playback from cloud, would a properly written native mobile app be faster than a web app run on Android?

I want to develop a backend cloud service that delivers full color compressed videos (as high def as possible) to Android smart phones for streaming playback. Would I get better playback if I properly develop a native mobile app or if I simply use the browser, maybe with some scripting, to access and play the video? I want the highest bandwidth playback I can get. Thanks!