if "/hello/world" path found, trigger route handler
else, if some route string ends with "*" and path starts with that string trigger route handler
Status and Headers
call start_response to send status code and headers. if you returns without calling it. It will send 200 OK status and some basic headers to client. if start_response is called without argsuments, it will send 200 OK status and some basic headers to client.
start_response has two arguments
status - status code as int(eg:-200) or str(eg:- "200 OK" or "200"). If status description(eg:-"OK") not supplied, it will find it.
headers - HTTP headers. can passed as,
list of tuples
dictionary
status code examples:-
send headers examples:-
list of tuples
dictionary
Send data
You can send following data types
str - string, text
bytes - binary
files - opened files
file-like object - streams(text, binary) like StringIOor BytesIO
iterables - list, tuple, setdictgenerators etc.
generators can send data one by one with time intervals. so it's like async Server
other -
Errors
example :-
Internal Server Error(500)
ZeroDivisionError :division by zero
report
report button starts reporting issue and logger will print error to python console
Traceback (most recent call last):
File "wsocket.py", line 881, in process_response
results = self.app(self.environ, self.start_response)
File "wsocket.py", line 1068, in wsgi
1/0
ZeroDivisionError: division by zero