This document has now been incorporated into the uWSGI documentation:
http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Steps with explanations to set up a server using:
http_code = "418" | |
match http_code: | |
case "200": | |
print("OK") | |
do_something_good() | |
case "404": | |
print("Not Found") | |
do_something_bad() | |
case "418": | |
print("I'm a teapot") |
import socket | |
a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
port = 9000 | |
location = ("127.0.0.1", port) | |
result_of_check = a_socket.connect_ex(location) | |
print(str(port)+" open" if result_of_check == 0 else str(port)+" not open") | |
a_socket.close() |
import datetime as dt | |
# 2020-10-14 12:00:00 | |
first_date = dt.datetime.strptime(first_date, '%Y-%m-%d %H:%M:%S') | |
# 2020-10-16 12:05:05 | |
second_date = dt.datetime.strptime(second_date, '%Y-%m-%d %H:%M:%S') | |
diff = second_date - first_date | |
hours = diff.days * 24 + diff.seconds // 3600 |
var cover = document.createElement("div"); | |
let css = ` | |
position: fixed; | |
pointer-events: none; | |
top: 0; | |
left: 0; | |
width: 100vw; | |
height: 100vh; | |
background-color: white; | |
mix-blend-mode: difference; |
# it's very easy to remove white spaces from strings | |
# it can be done using many methods but here we will disscuss some efficient one | |
# 1. Using replace() | |
s = " h a c k you r co de " # this function doesn't modify original string | |
new_s = s.replace(" ","") # here new_s holds new string with no blank spaces at all. | |
print(new_s) | |
# the output will be "hackyourcode" | |
# 2. Using join() and split() |
def buildTree(tasks, parentId=0): | |
branch = [] | |
for task in tasks: | |
if task['parent_id'] == parentId: | |
children = buildTree(tasks, task['id']) | |
if children: | |
# print(list(children.keys())) | |
task['children'] = children | |
else: |