Skip to content

Commit

Permalink
updated web-dev in python
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabkumar7 committed Feb 7, 2024
1 parent a8242d9 commit 1548645
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions docs/days/day5.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Python is quite capable when it comes to web development, and there are a variety of frameworks and modules are available for it. These can be used to create web applications.
Flask, Django, and Pyramid are a few well-known frameworks. The choice of framework will rely on the project's requirements. Each of these frameworks has advantages and disadvantages of its own.

## Creating a basic web app using Flask:
## Creating a basic web app using Flask

Creating a basic web application using Flask: Flask is a micro web framework for Python that is easy to learn and use. It provides a simple way to create web applications and APIs using Python. Here are some examples of Flask code for creating a basic web application:

Expand All @@ -18,7 +18,7 @@ def hello_world():
```
This code creates a Flask application and defines a single route for the root URL (/). When the user visits the URL, the hello_world() function is called and returns the string 'Hello, World!'.

## Working with databases:
## Working with databases

The majority of online applications need some sort of permanent storage, and Python offers a number of modules and frameworks for doing so. Popular options include Django ORM, Peewee, and SQLAlchemy. Here is an illustration of how to work with a SQLite database using SQLAlchemy:

Expand All @@ -39,9 +39,17 @@ def index():
users = User.query.all()
return render_template('index.html', users=users)
```

This code creates a SQLite database and a User table using SQLAlchemy. The index() function queries the database for all users and passes them to the template for rendering.

Having a good understanding of how these web apps work, will help you with automation and deployment when it comes to practicing DevOps.
You can dive deeper into how you can build APIs using Python and serverless technologies like AWS Lambda, Azure Functions etc.
You can dive deeper into how you can build APIs using Python and serverless technologies like [AWS Lambda](https://aws.amazon.com/lambda/), [Azure Functions](https://azure.microsoft.com/en-ca/products/functions#:~:text=Azure%20Functions%20is%20an%20event,highest%20level%20of%20hardware%20abstraction.) etc.

I have a demo on [how I built a serverless resume API](https://github.com/rishabkumar7/AzureResumeAPI).

## Building APIs in Python

Creating an API (Application Programming Interface) in Python can be a straightforward process, thanks to various frameworks and libraries available. Three popular methods to set up a web API in Python: Flask, FastAPI, and Django Rest Framework.

In the following video, I showcase all three of them:
<iframe width="700" height="400" src="https://www.youtube.com/embed/k8eu2QDikIc?si=ynwIjeR3ruC5LVhs" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

0 comments on commit 1548645

Please sign in to comment.