1 / 7

Web Development Services Arslan Rajpoot

Web Development Services Arslan Rajpoot

Ahmad276
Download Presentation

Web Development Services Arslan Rajpoot

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Development Services The previous articles showed you what communication between a web client and a server looks like, the nature of HTTP requests and responses, and what a server-side application needs to do in order to respond to requests from a web browser. Armed with this knowledge, it's time to explore how a web framework can simplify these tasks and show you how to choose a framework for your first server-side application. The following section illustrates some key points using some code snippets from web frameworks. Don’t worry too much if you can’t fully understand the code. Our "Framework Details" module will help you fully understand. Overview: Server-side frameworks (also known as "web application frameworks") make it easier to write, maintain, and extend web applications. They provide tools and libraries to implement simple, common development tasks, including routing processing, database interaction, session support and user authentication, formatted output (e.g. HTML, JSON, XML,DMT), and improved security against network attacks. The next section details how web frameworks simplify web application development. Then, I'll lay out some criteria for choosing a web framework and lay out some options for you. What can web frameworks do for you? You don't have to use a server-side web framework, but we strongly recommend that you do - it will make your life better. In this section, we talk about the functions usually provided by web frameworks (this does not mean that every framework will definitely provide all the functions below!)

  2. Handle HTTP requests and responses directly As we know from the previous article, web servers and browsers communicate via the HTTP protocol - the server waits for an HTTP request from the browser and then returns the relevant information in the HTTP response. Web frameworks allow you to write code with a simple syntax that generates code that handles these requests and responses. This means your work becomes easier, your interactions become easier, and you use more abstract code instead of low-level code. Each "view" function (handler of the request) accepts an HttpRequest object containing the request information, and is required to return an HttpResponse containing formatted output (a string in the example below). Route the request to the relevant handler Most sites offer a range of different resources, accessed through specific URLs. If you put them all in one function, the website will become difficult to maintain. So web frameworks provide a simple mechanism to match URLs with specific handler functions. This approach is also good for website maintenance because you only need to change the URL used to deliver specific functionality without changing any underlying code. Different frameworks use different mechanisms for matching. For example, the Flask (Python) framework uses decorators to increase view routing. Make it simple to get data from requests

  3. There are many ways data can be encoded in HTTP requests. An HTTP GET request to obtain a file or data from a server may be encoded as required in the URL parameters or in the URL structure. An HTTP POST request that updates data on the server will include update information like "POST data" in the request body. HTTP requests may also include live session and user information in client cookies. Web frameworks provide a programming language-appropriate mechanism for obtaining this information. For example, the HttpRequest object that Django passes to the view function contains the method and attributes for obtaining the target URL, the type of request (such as an HTTP GET), GET or POST parameters, cookie or session data, etc. Django can also pass encoded information in the URL structure by defining "crawl patterns" in the URL match table (like the last line in the encoding snippet above). Abstract and simplify database interfaces The website uses databases to store information shared with users and users' personal information. Web frameworks usually provide a database layer to abstract the read, write, and query and delete operations of the database. This abstraction layer is called an object-relational mapper (ORM). There are two benefits to using an object-relational mapper: You can replace the underlying database without changing the code that uses the database. This allows developers to optimize the characteristics of different databases depending on their use. Simple data validation can be built into the framework. This would make it easy to check whether the data is stored in the database field in the correct way or in a specific format (such as an email address), and is not malicious (a hacker can exploit specific encoding patterns to do things like delete database records). Illegal operation). For example, the Django framework provides an object-relational mapping and calls the structure used to define database records a model. The model specifies the type of fields to be stored, and may also provide validation of the information to be stored (for example, an email field only allows valid email addresses). Fields may also indicate maximum information size, default values, option lists, help documentation, form labels, etc. This model does not declare any underlying database information, because this is a configuration information that can only be changed by our code. The first code snippet below shows a simple Django model designed for a Team object. This model uses character fields to store a team's name and level, and also specifies the maximum number of characters used to store each record. Team level is an enumeration field, so we also provide a match between the data being stored and the options being displayed, as well as specifying a default value. Django models provide a simple query API for searching the database. This can be done by simultaneously matching a range of fields using different criteria (e.g. exact, case-insensitive, greater

  4. than, etc.), and supports some complex statements (e.g. you can specify that you are searching for U11 level teams with names starting with Teams starting with "Fr" or ending with "al"). The second code snippet shows a view function (resource handler) that is used to display all teams at the U09 level - by specifying that all teams whose team level fields exactly match 'U09' are filtered out (note how the filtering rules are passed to filter ( ), which is treated as a variable: team_level__exact, consisting of the field name, the match type, and the double underscore that separates them). Render data Web frameworks often provide templating systems. These allow you to structure the output document, using placeholders for that data that will be added when the page is generated. Templates are often used to generate HTML, but they can also be used to generate some other documents. The framework provides a mechanism that makes it easy to generate data in other formats from stored data, including JSON and XML. For example, Django templates allow you to specify variables by using "double curly braces" (such as {{variable name}}). When the page is rendered, these variables will be replaced by the values passed from the view function. The template system also provides expression support (implemented through the syntax {% expression %}), which allows templates to perform simple operations such as iterating over a list of values passed to the template. The code snippet below shows how they work. The following content follows the "youngest team" example from the previous section, where the HTML template is passed a list of values called youngest teams via the view function. In the HTML skeleton we have a representation that initially checks

  5. whether the youngest teams variable exists, and then iterates inside a for loop. On each iteration the template displays the team's team name value as a list element. How to choose a web framework There are tons of web frameworks for almost every language you want to use (we've listed some of the more popular ones in the section below). With so many options out there, it can be difficult to decide which framework to choose to provide the best start for your new web application. Some factors that influence your decision include: Learning cost: Learning a web framework depends on your familiarity with the underlying language, the consistency of its API, the quality of the documentation, and the size and activity of the community. If you have no programming foundation at all, then consider Django (it is the easiest to learn based on the above criteria). If you have become part of a development team that has significant development experience in a certain language or a certain framework, then stick to the relevant framework. Efficiency: Efficiency refers to the measurement of how much you can create a new feature once you are familiar with a framework, including the cost of writing and maintaining code (because you cannot write new features after the previous features break). Most of the factors that affect efficiency are similar to learning costs - for example, documentation, community, programming experience, etc. —— other factors include: Framework Purpose/Origin: Some frameworks were originally designed to solve a specific type of problem, and it is best to take these constraints into account when building the app. For example, Django is designed to support news websites, so it is ideal for blogs or other websites that contain published content. In contrast, Flask is a relatively lightweight framework and therefore suitable for generating apps that run on embedded devices.

  6. Opinionated vs opinionated: An opinionated framework means that when solving a specific problem, there is always a recommended best solution. Opinionated frameworks tend to be more product- oriented when you are trying to solve some common problems, because they will lead you in the right direction, although sometimes they are not so flexible. Some web frameworks include by default tools/libraries for any problem developers may encounter, while some lightweight frameworks expect developers to choose appropriate solutions from separate libraries (Django is the former) An instance, while Flask is a lightweight instance). An all-inclusive framework is usually easy to get started because you already have everything you need, and chances are it's already integrated and well documented. Whereas a smaller framework contains everything you need (or will need in the future), it will only be able to run in a more restricted environment and require learning a smaller, simpler subset. Whether to choose a framework that encourages good development practices: For example, a framework that encourages the Model-View-Controller structure to separate code into logical functions will be more maintainable code than one that does not expect this from developers. In terms of framework. Likewise, framework design profoundly affects how easy it is to test and reuse code. Framework/programming language performance: Generally speaking, "speed" is not the most important factor in the choice, and even, relatively speaking, Python, which runs very slowly, is enough for a medium-sized website running on a medium hard drive. . The obvious speed advantage of other languages (C++/JavaScript) is likely to be offset by the cost of learning and maintenance. Cache support: As your website becomes more and more successful, you may find that it can no longer properly handle the large number of requests it receives. At this point, you might start thinking about adding caching support. Caching is an optimization that means you save all or most of your website requests so that they don't need to be recalculated in subsequent requests. Returning a cache request is much faster than recalculating it again. Caching can be built into your code, or on the server (see reverse proxy). Web frameworks have varying levels of support for defining cacheable content. Scalability: Once your website becomes very successful, you will find that the benefits of caching are exhausted, and even the vertical capacity reaches the limit (running the program on more powerful hardware). At this point, you may need to scale horizontally (spreading your website across several servers and databases to load) or scale "geographically" because some of your customers are far away from your server. The framework you choose will affect how easy it is to scale your website.

  7. Cybersecurity: Some web frameworks provide better support for resolving common cyberattacks. For example, Django eliminates all user input from HTML. Therefore JavaScript entered from the user side will not be run. Other frameworks also provide similar functionality, but usually not enabled directly by default. There may be other reasons, including licensing, whether the framework is in a dynamic development process, etc. If you are a complete beginner, then you may choose your framework based on "ease of learning". Besides the "ease of learning" of the language itself, high-quality documentation/tutorials to help newbies and an active community are your most valuable resources. In subsequent lessons, we chose Django (Python) and Express (Node/JavaScript) to write our examples, mainly because they are easy to get started and have strong support. What are some good frameworks? Let's move on and discuss a few specific server-side frameworks. The server-side frameworks below represent some of the most popular ones today. They have everything you need to be productive - they are open source, constantly evolving, have a passionate community of people creating documentation and helping users on discussion boards, and are used in on many high-quality websites. There are of course many other great frameworks out there that you can explore using search engines.

More Related