userscripts – Delete a user if he puts his email in a form and presses “delete button”

As an exercise, I am trying to create a form. This form will be connected to a database. I managed to get the user’s information from the form and to put them in my db. But let’s think a user wants to delete “its row”. How can I do it? My thought is: I can create another form and put only “email” field. email is also my db’s primary key. So, if the user puts his email in the “delete form”, he will cancel his record from my db. (I know, this is not really realistic, I just want to learn the basis to do it).

By far, this is my code to put the new user into the db:

async function myFetch(myUser) {
    let response = await fetch('http://localhost:3000/register/',  {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify(myUser),
    });
    if (!(response.status >= 200 && response.status < 300)) {
        throw Error(response.statusText);
    }
    let data = await response.text();  // o response.json()
    document.getElementById("risultato").innerText = "Registered!";
    nuovaRegistrazione.style.visibility = 'visible';
}

function registra(myUser) {
    myFetch(myUser)
    .catch(err => {
        if (err.message == "Conflict") {
            document.getElementById("risultato").innerText = "Errore - already exists";
        }
        else if (err.message == "Failed to fetch"){
        document.getElementById("risultato").innerText = "Errore - server";
        }
    });
}

Can you help me doing something similar to delete? I thought it could be something with method “DELETE” instead of “POST”, but it’s not working.

userscripts – File saving location in python

I am trying to save a downloaded file to a location that is different from the source file. In short, my script is as follows;
import os.path
import urllib.request

choice = input ("Enter a file name that includes the extension")
choice2 = input ("Enter a path for the file save location")
links = open (choice)
for link in links:

# Get one line of text (e.g. http://server/files/grades.doc),
urllib.request.urlretrieve(link)
print(link)
# then get the filename from the end of the URL
link = link.strip()
filename = link.rsplit('/', 1)(-1)
print(filename)
# Does this file exist in this folder? If not, download it
if not (os.path.isfile(filename)):
    print('Downloading: ' + filename)
    try:
        urllib.request.urlretrieve(link, filename)
        print("File size was", os.path.getsize(filename))
    except Exception as inst:
        print(inst)
        print('  Encountered unknown error. Continuing.')

# File exists; don't download
else:
    print("This file exists already.")

print ("Download finished")

if os.path.exists (& # 39; 10meg.test & # 39;):
os.remove (& # 39; 10meg.test & # 39;)
print ("10meg.test successfully removed")
plus:
print ("10meg.test not found")
if os.path.exists (& # 39; 50meg.test & # 39;):
os.remove (& # 39; 50meg.test & # 39;)
print ("50meg.test successfully removed")
plus:
print ("50meg.test not found")

Any help is really appreciated.