Product Search


Serverside Web Frameworks


The previous article showed you what the communication between web clients and servers looks like, the nature of HTTP requests and responses, and what a server-side web application needs to do in order to respond to requests from a web browser. With this knowledge under our belt, it's time to explore how web frameworks can simplify these tasks, and give you an idea of how you'd choose a framework for your first server-side web application. The following sections illustrate some points using code fragments taken from real web frameworks. Don't be concerned if it doesn't all make sense now; we'll be working you through the code in our framework-specific modules. Server-side web frameworks (a.k.a. They provide tools and libraries that simplify common web development tasks, including routing URLs to appropriate handlers, interacting with databases, supporting sessions and user authorization, formatting output (e.g. HTML, JSON, XML), and improving security against web attacks.


The next section provides a bit more detail about how web frameworks can ease web application development. We then explain some of the criteria you can use for choosing a web framework, and then list some of your options. What can a web framework do for you? Web frameworks provide tools and libraries to simplify common web development operations. You don't have to use a server-side web framework, but it is strongly advised - it will make your life a lot easier. This section discusses some of the functionality that is often provided by web frameworks (not every framework will necessarily provide all of these features!). As we saw in the last article, web servers and browsers communicate via the HTTP protocol - servers wait for HTTP requests from the browser and then return information in HTTP responses. Web frameworks allow you to write simplified syntax that will generate server-side code to work with these requests and responses. This means that you will have an easier job, interacting with easier, higher-level code rather than lower level networking primitives.


The example below shows how this works in the Django (Python) web framework. Every "view" function (a request handler) receives an HttpRequest object containing request information, and is required to return an HttpResponse object with the formatted output (in this case a string). Most sites will provide a number of different resources, accessible through distinct URLs. Handling these all in one function would be hard to maintain, so web frameworks provide simple mechanisms to map URL patterns to specific handler functions. This approach also has benefits in terms of maintenance, because you can change the URL used to deliver a particular feature without having to change the underlying code. Different frameworks use different mechanisms for the mapping. For example, the Flask (Python) web framework adds routes to view functions using a decorator. While Django expects developers to define a list of URL mappings between a URL pattern and a view function.


Data can be encoded in an HTTP request in a number of ways. An HTTP GET request to get files or data from the server may encode what data is required in URL parameters or within the URL structure. An HTTP POST request to update a resource on the server will instead include the update information as "POST data" within the body of the request. The HTTP request may also include information about the current session or user in a client-side cookie. Web frameworks provide programming-language-appropriate mechanisms to access this information. For example, the HttpRequest object that Django passes to every view function contains methods and properties for accessing the target URL, the type of request (e.g. an HTTP GET), GET or POST parameters, cookie and session data, etc. Django can also pass information encoded in the structure of the URL by defining "capture patterns" in the URL mapper (see the last code fragment in the section above).


Websites use databases to store information both to be shared with users, and about users. Web frameworks often provide a database layer that abstracts database read, write, query, and delete operations. This abstraction layer is referred to as an Object-Relational Mapper (ORM). You can replace the underlying database without necessarily needing to change the code that uses it. This allows developers to optimize for the characteristics of different databases based on their usage. Basic validation of data can be implemented within the framework. This makes it easier and safer to check that data is stored in the correct type of database field, has the correct format (e.g. an email address), and isn't malicious in any way (hackers can use certain patterns of code to do bad things such as deleting database records). For example, the Django web framework provides an ORM, and refers to the object used to define the structure of a record as the model. The model specifies the field types to be stored, which may provide field-level validation on what information can be stored (e.g. an email field would only allow valid email addresses).



Featured Products






Articles


How To Save Your Computer From Coffee Damage
Taking Your Golf Games To A Whole New Level
Top Subliminal Products For Your Computer
Vehicle Diagnostics Maintaining Todays One Of The Important Aspects
Getting The Top Golf Accessories
Getting Started On Your First Hiking Adventure
My Computer Is Making A Strange Noise
Is Money Saving The Sole Consideration For Buying Wholesale Designer Handbags
Web3 Vs Metaverse Whats The Difference
Parker Jeans Instability With Cosmic Rays
Six Common Car Problems That You Can Fix Using Repair Manual
Make Smart Move by Paying Minimum Cash for your Home
Be Careful When Shopping For 4x4 Trucks Online
4 Potential Reasons Why To Buy Bluetooth Speakers Hk And Headphones
By The Middle Of 224
Shipping Drones and Feasibility
Tech Mahindra Accenture And Hcl Placement Papers Offer Significant Support For Jobs In These Sector
Why Lifespan Fitness Is Happy During The Economic Recession
Who Is Alfonso Soriano
Monster Galaxy The Zodiac Islands Review The Attractive And Addicting Pokemon Game
The Greatest Advantages Of Zero Turn Mowers
Military Houses For Sale In Virginia
Patchwork Sofas Are Certainly Not Your Granny S Fainting Couch
Art Of Mountaineering A Growing Interest Among The Youth And Popularity Of Mountain Bikes
5 Important Facts Everyone Should Know About Synthetic Grass
Quick And Easy Meal Prep Ideas
Points To Consider When Making Your Choice Of Luggage
Website Development Costs In India
Web Designing Company In Bangalore
Why You Should Choose Ergonomic Chairs
Points To Be Considered While Choosing Secret Santa Gifts
24 TFT 5MP Digital Camcorder Orange DV8A
Can you Identify these Generation 1 Pokemon from Gameboy Screenshots?
Right Procedure To Follow On How To Grow Magic Mushrooms
Working Of Golf Simulators
Reviews And Complaints Coleman Furniture
Wallpaper Murals How To Create That Dramatic Impression
Sony Car Stereos
Dish Network Brings Exciting Christmas Offers
Video Surveillance With Ip Network Cameras
Safe Motorbike Accessories For You
Wholesaledeals Review For Valuable Information About Ecommerce Business
Whats So Special About 3d Tv
Camping Trips Can Be Comfortable
Buy Wedding Rings With Help of a Guide
Choosing A High Quality Microwave
Buy The Best Deal in Used Cars Irrespective of Your City
How To Look After Your Ladies Boots In Harsh Weather Conditions
What To Check In Car Reviews
5 Reasons Your Iphone Or Ipad Need Mobile Accessories