forked from DogukanUrker/FlaskBlog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.py
More file actions
73 lines (63 loc) · 1.71 KB
/
helpers.py
File metadata and controls
73 lines (63 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import ssl
import smtplib
import secrets
import sqlite3
from os import mkdir
from random import randint
from os.path import exists
from datetime import datetime
from email.message import EmailMessage
from passlib.hash import sha256_crypt
from flask import render_template, Blueprint
from forms import (
loginForm,
signUpForm,
commentForm,
createPostForm,
passwordResetForm,
changePasswordForm,
changeUserNameForm,
)
from flask import (
Flask,
flash,
request,
session,
redirect,
Blueprint,
render_template,
send_from_directory,
)
def currentDate():
return datetime.now().strftime("%d.%m.%y")
def currentTime(seconds=False):
match seconds:
case False:
return datetime.now().strftime("%H:%M")
case True:
return datetime.now().strftime("%H:%M:%S")
def message(color, message):
print(
f"\n\033[94m[{currentDate()}\033[0m"
f"\033[95m {currentTime(True)}]\033[0m"
f"\033[9{color}m {message}\033[0m\n"
)
logFile = open("log.log", "a")
logFile.write(f"[{currentDate()}" f"|{currentTime(True)}]" f" {message}\n")
logFile.close()
def addPoints(points, user):
connection = sqlite3.connect("db/users.db")
cursor = connection.cursor()
cursor.execute(
f'update users set points = points+{points} where userName = "{user}"'
)
connection.commit()
message("2", f'{points} POINTS ADDED TO "{user}"')
def getProfilePicture(userName):
connection = sqlite3.connect("db/users.db")
cursor = connection.cursor()
cursor.execute(
f'select profilePicture from users where lower(userName) = "{userName.lower()}"'
)
return cursor.fetchone()[0]