Itep 304 Lesson1
Itep 304 Lesson1
HTTP (Hypertext Transfer Protocol), is the underlying format that is used to structure request and
responses for effective communication between a client and a server.
HTTP request methods are the assets that indicate the specific desired action to be performed on a given
resource.
How do HTTP Request works? As the intermediary transportation method between a client/application and
a server.
Web Status Codes also known as HTTP Response Status Code is issued by a server in response to a
client's request made to the server.
The Internet Assigned Numbers Authority (IANA) maintains the official registry of HTTP status
codes.
2xx successful – the request was successfully received, understood, and accepted
200 – OK Standard response for successful HTTP requests. The actual response will depend on the request
method used.
201 – Created The request has been fulfilled, resulting in the creation of a new resource.
202 – Accepted The request has been accepted for processing, but the processing has not been completed.
203 – Non-Authoritative Information (since HTTP/1.1) The server is a transforming proxy that received a
200 OK from its origin, but is returning a modified version of the origin’s response.
204 – No Content The server successfully processed the request, and is not returning any content.
205 – Reset Content asks that the requester reset its document view, and is not returning any content.
206 – Partial Content (RFC 7233) The server is delivering only part of the resource (byte serving) due to a
range header sent by the client.
207 – Multi-Status (WebDAV; RFC 4918) can contain a number of separate response codes, depending on
how many sub-requests were made.
208 – Already Reported (WebDAV; RFC 5842) already been enumerated in a preceding part of the (multi-
status) response, and are not being included again.
226 – IM Used (RFC 3229) The server has fulfilled a request for the resource, and the response is a
representation of the result of one or more instance-manipulations applied to the current instance.
3xx redirection – further action needs to be taken in order to complete the request
300 – Multiple Choices Indicates multiple options for the resource from which the client may choose
301 – Moved Permanently This and all future requests should be directed to the given URI (Uniform Resource
Identifier).
302 – Found (Previously “Moved temporarily”) Tells the client to look at (browse to) another URL. 302 has
been superseded by 303 and 307. The HTTP/1.0 specification (RFC 1945) required the client to perform a
temporary redirect (the original describing phrase was “Moved Temporarily”), but popular browsers
implemented 302 with the functionality of a 303.
303 – See Other (since HTTP/1.1) The response to the request can be found under another URI (Uniform
Resource Identifier) using the GET method.
304 – Not Modified (RFC 7232) Indicates that the resource has not been modified since the version specified
by the request
305 – Use Proxy (since HTTP/1.1) The requested resource is available only through a proxy, the address for
which is provided in the response.
306 – Switch Proxy No longer used. Originally meant “Subsequent requests should use the specified proxy”.
307 – Temporary Redirect (since HTTP/1.1) In this case, the request should be repeated with another URI;
however, future requests should still use the original URI.
308 – Permanent Redirect (RFC 7538) The request and all future requests should be repeated using another
URI.
4xx client error – the request contains bad syntax or cannot be fulfilled; class of status code is intended for
situations in which the error seems to have been caused by the client .
400 – Bad Request The server cannot or will not process the request due to an apparent client error
401 – Unauthorized (RFC 7235) Similar to 403 Forbidden, but specifically for use when authentication is
required and has failed or has not yet been provided. 401 semantically means “unauthorized”, the user does not
have valid authentication credentials for the target resource.
402 – Payment Required Reserved for future use. The original intention was that this code might be used as
part of some form of digital cash or micropayment scheme, as proposed.
403 – Forbidden The request contained valid data and was understood by the server, but the server is refusing
action. This may be due to the user not having the necessary permissions for a resource or needing an account of
some sort, or attempting a prohibited action (e.g.
404 – Not Found The requested resource could not be found but may be available in the future. Subsequent
requests by the client are permissible.
405 – Method Not Allowed A request method is not supported for the requested resource; for example, a GET
request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
406 – Not Acceptable The requested resource is capable of generating only content not acceptable according to
the Accept headers sent in the request.
407 – Proxy Authentication Required (RFC 7235) The client must first authenticate itself with the proxy.
408 – Request Timeout The server timed out waiting for the request. According to HTTP specifications: “The
client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the
request without modifications at any later time.”
5xx server error – the server failed to fulfil an apparently valid request
GETTING WITH FLASK
from flask import Flask
A web framework is designed to provide a standard way to build and deploy web applications; provides libraries for
databases, which allows programmers to reuse code.
Flask is a microframework that is simple yet extendable; can also be used for complex programs.
The __name__ evaluates to the name of the current module. view function app = Flask(__name__)
Jinja2 is the template engine used by Flask which allows programmers to code within HTML files.
The render_template() function is used to generate output from a template(or HTML) file