Wednesday, July 26, 2023

Environmental Science - Class 1, Topic: Animal Around Us Animals come in many shapes and sizes, inhabit different places, and live in different ways. Biodiversity is the term that describes the many different

 Animals come in many shapes and sizes, inhabit different places, and live in different ways. Biodiversity is the term that describes the many different ...


ENV Grade 5  Chapter 4 Animal Around Us

Subscribe to my channel : https://www.youtube.com/channel/UCJojbxGV0sfU1QPWhRxx4-A

Thanks for watching. Please leave a like, comment and remember to subscribe!


0:00 Animal Groups

Mammals Birds Reptiles Amphibians Fish Invertebrates


0:10 Mammals are warm-blooded vertebrates that possess mammary glands and have hair or fur on their bodies.

Habits: Mammals give birth to live young and nurse them with milk produced by their mammary glands. They have diverse habitats, from terrestrial to aquatic.

Examples: Lion, Elephant, Dolphin, Kangaroo, Giraffe


0:20 Birds are warm-blooded vertebrates with feathers, beaks, and lay hard-shelled eggs.

Habits: Birds have the ability to fly and have various adaptations for different habitats. They exhibit a wide range of behaviors and have intricate mating rituals.

Examples: Eagle, Penguin, Parrot, Hummingbird, Ostrich


0:30 Reptiles are cold-blooded vertebrates covered in scales or plates and lay soft-shelled eggs.

Habits: Reptiles have dry and scaly skin and are adapted to various environments, from deserts to rainforests. They regulate their body temperature through external sources.

Examples: Snake, Turtle, Crocodile, Lizard, Chameleon


0:40 Amphibians are cold-blooded vertebrates that undergo metamorphosis from aquatic larvae to terrestrial adults.

Habits: Amphibians typically have moist skin, and most species begin their lives in water and later move to land. They require water for reproduction.

Examples: Frog, Salamander, Newt, Toad, Caecilian


0:50 Fish are cold-blooded vertebrates with gills for respiration and typically have fins and scales.

Habits: Fish are adapted for aquatic life, and they inhabit a wide range of environments, including freshwater and saltwater. They have diverse feeding strategies. They require water for reproduction.

Examples: Salmon, Clownfish, Shark, Trout, Angelfish.


1:10 Invertebrates are animals without a backbone or spinal column

Habits:  Invertebrates constitute the majority of animal species on Earth and have diverse forms and habitats. They play crucial roles in ecosystems.

Examples: Butterfly, Spider, Snail, Jellyfish, Ant


1:20 Terrestrial Animals Aquatic Animals Arboreal Animals Aerial Animals Amphibians


1:30 Terrestrial animals live on land.

They have adapted to survive in various habitats such as deserts, forests, and grasslands.

They have legs or other means of moving on land.

Many terrestrial animals dig burrows or build nests to live in.

Examples lions, elephants, rabbits, and snakes.


1:40 Aquatic animals live in water, such as oceans, rivers, and lakes.

They have adaptations for swimming, diving, or floating in water.

They have gills or lungs to breathe underwater.

Some aquatic animals, like seals, can live both on land and in water.

Examples fish, dolphins, turtles, and whales.


1:50 Arboreal animals live in trees and are adapted for life in the canopy.

They have strong limbs and grasping hands or feet for climbing.

They often have long tails to help with balance.

Arboreal animals build nests or sleep in tree hollows.

Examples monkeys, sloths, koalas, and squirrels.


2:10 Aerial animals can fly or spend a significant amount of time in the air.

They have wings or other structures that allow them to glide or soar.

They have lightweight bodies and streamlined shapes for efficient flight.

Aerial animals migrate over long distances to find food or suitable breeding grounds.

Examples birds, bats, butterflies, and insects.


2:20 Amphibians are vertebrate animals that live both in water and on land.

They go through a metamorphosis, starting as aquatic larvae (like tadpoles) and then developing into terrestrial adults.

They have moist skin that helps them breathe.

Amphibians lay eggs in water, and their young undergo a transformation to adapt to a land-dwelling lifestyle.

Examples frogs, toads, salamanders, and newts.


some people have cat, parrot or dog in their homes.

These animals are kept for fun. ...

Goat, cow, buffalo, ox, donkey, etc are domestic animals. ...

Tiger, lion, fox, bear, deer, etc., are wild animals. ...

Cow, buffalo and goat are milk giving animals. ...

Mammals give birth to their babies and feed them with their own milk.


What are 4 animals around us?

What are the 10 uses of domestic animals?

What are the larger animal around us?

What are the names of the 10 domestic animals?

What are the 9 domestic animals?

What are 10 animals?

What are the 12 animals in English?

What are top 5 animals?

What are a list of animals?

What are the six domestic animals?

What are the 4 most popular animals?

What are 6 animals that live on land?

What is the smallest animal?

What are the top 3 largest animals?

What are animals for Class 5?

What are 20 domestic animals?

What is the name of 20 pet?

What are wild animals for kids?

What are the 4 types of animals?

What animal is 23?

Why is there 12 animals?

What are 3 types of animals?

What are 2 types of animals?

What are the 11 groups of animals?

Who are wild animals?

What type of animal is a fish?

How many animals are there?

What are 5 animal uses?

Which animal is useful to us?

What are the uses of animals 20?

What are 7 examples of wild animals?

What is pet animals name?

What are animals for Class 1?

What are family pets?

Is cow is a pet animal?

Why are animals pets?

What is the strongest animal?

What is the 2nd biggest animal?

What is the tallest animal?


Friday, July 14, 2023

eChannelling Find a Doctor Channel Appointments Online Sri Lanka Executive Summary Introduction Objectives Scope of Work Methodology Technical Requirements Timeline Budget Risk Analysis

Project Proposal: eChannelling Find a Doctor Channel Appointments Online Sri Lanka Doc990

Sample Project

I. Executive Summary:

   - Brief overview of the project and its objectives.

   - Description of the proposed solution for online channel appointments in hospitals and medical centers.


II. Introduction:

   - Background information on the current healthcare system and challenges faced.

   - Importance of implementing an online platform for doctor channel appointments.


III. Objectives:

   - Clearly defined goals and objectives of the project.

   - Key deliverables to be achieved.


IV. Scope of Work:

   - Description of the features and functionalities to be included in the online platform.

   - Identification of the target audience (patients, doctors, hospitals, medical centers).

   - Listing of the hospitals and medical centers to be included in the network.


V. Methodology:

   - Overview of the approach and methodology to be used in the project.

   - Detailed steps for the development, implementation, and deployment of the online platform.

   - Integration with existing hospital systems and appointment scheduling processes.


VI. Technical Requirements:

   - Description of the technology stack to be used for the platform development.

   - Infrastructure and hosting requirements.

   - Data security and privacy considerations.


VII. Timeline:

   - Proposed timeline for the project, including major milestones and deliverable dates.

   - Phased approach, if applicable, to ensure a smooth implementation.


VIII. Budget:

   - Estimated budget for the project, including development costs, infrastructure expenses, and ongoing maintenance.

   - Justification for the budget allocation.

   - Potential sources of funding, if applicable.


IX. Risk Analysis:

   - Identification of potential risks and challenges associated with the project.

   - Mitigation strategies to address the identified risks.

   - Contingency plans for unexpected issues or delays.


X. Stakeholder Engagement:

   - Description of the key stakeholders involved in the project (hospitals, medical centers, doctors, patients).

   - Communication and engagement plan for stakeholders throughout the project lifecycle.


XI. Evaluation and Success Metrics:

   - Criteria for evaluating the success of the project.

   - Key performance indicators (KPIs) to measure the effectiveness of the online platform.

   - Plans for gathering feedback from users and making necessary improvements.


XII. Conclusion:

   - Summary of the proposed project.

   - Importance of implementing the online platform for doctor channel appointments.

   - Call to action for stakeholders to support and endorse the project.


XIII. Appendices:

   - Supporting documents, such as project diagrams, system architecture, wireframes, etc.

   - Any additional relevant information.


Please note that this is a general outline for a project proposal and may require customization based on the specific requirements and preferences of the organization or funding entity.


 Functions:

1. User registration and authentication.

2. Search for doctors based on specialty, location, and availability.

3. Book appointments with doctors online.

4. Manage and view upcoming appointments.

5. Cancel or reschedule appointments.

6. View doctor profiles and their qualifications.

7. Provide feedback and ratings for doctors.

8. Receive notifications and reminders for appointments.

9. Integration with hospital and medical center systems for real-time availability updates.

10. Provide support and assistance to users.


Features:

1. User registration and login functionality.

2. Advanced search filters for finding doctors based on various criteria.

3. Appointment booking and scheduling with preferred doctors.

4. Secure payment gateway integration for online payment of consultation fees.

5. Real-time availability of doctors and appointment slots.

6. Doctor profiles showcasing their experience, qualifications, and specialties.

7. Ratings and reviews for doctors based on patient feedback.

8. Automated notifications and reminders for upcoming appointments.

9. Seamless integration with hospital systems for data synchronization.

10. Responsive design for access on multiple devices.


Main Modules:

1. User Management:

   - User registration

   - User login

   - User profile management


2. Doctor Search and Booking:

   - Doctor search functionality

   - Doctor profile display

   - Appointment booking


3. Appointment Management:

   - Upcoming appointments display

   - Appointment cancellation and rescheduling

   - Notifications and reminders


4. Feedback and Ratings:

   - Feedback submission for doctors

   - Rating system for doctors


5. Integration with Hospital Systems:

   - Real-time availability updates

   - Data synchronization with hospital systems


Sub Modules:

1. Authentication:

   - Registration validation

   - Password reset functionality


2. Search Filters:

   - Specialty-based search

   - Location-based search

   - Availability-based search


3. Payment Gateway Integration:

   - Secure payment processing

   - Payment confirmation


4. Doctor Profile:

   - Qualifications and experience display

   - Patient reviews and ratings


5. Notifications and Reminders:

   - Appointment confirmation

   - Appointment reminders


Class Names:

1. User

2. Doctor

3. Appointment

4. Feedback

5. Payment

6. Notification


Table Names:

1. Users

2. Doctors

3. Appointments

4. Feedbacks

5. Payments

6. Notifications


Use Case Names:

1. User Registration

2. User Login

3. Search for Doctors

4. Book an Appointment

5. View Upcoming Appointments

6. Cancel/Reschedule an Appointment

7. Submit Feedback for a Doctor

8. Rate a Doctor

9. Process Payment

10. Receive Appointment Notifications

For more guidance on Projects & !!!

Online Individual / Group classes in English / Sinhala / Tamil. Sample Projects/Assignments Exam Papers, Tutorials, Notes and Answers & more ..

CALL +94 777 33 7279 | EMAIL  ITCLASSSL@GMAIL.COM


Tuesday, June 27, 2023

Online Social Media Order Management System Project Proposal Introduction Scope Objective Details of Modules Classes Database Tables UCSC UoM Sri Lanka

Project Proposal Online Social Media Order Management System

Sample Project

1. Introduction:

The Online Social Media Order Management System is designed to streamline the order placement process for a business that receives orders through various social media channels, including calls, comments, messages, and emails. The system automates the order collection, stock management, price verification, invoice generation, order tracking, delivery tracking, and order/payment reminders. By implementing this system, the business aims to enhance customer satisfaction, improve efficiency, and reduce manual efforts in managing orders.


2. Scope:

The scope of the Online Social Media Order Management System includes the following:

- Integration with social media platforms to receive orders (calls, comments, messages, and emails)

- Auto-reply functionality to acknowledge order placement

- Order collection and storage in a database

- Real-time stock management and alerts for out-of-stock items

- Integration with supplier systems for restocking requests

- Integration with a pricing database to fetch the latest price details

- Invoice generation with customizable templates

- Order tracking with status updates

- Delivery tracking with shipping information and estimated delivery dates

- Automated reminders for pending orders and payments


3. Objective:

The main objectives of the Online Social Media Order Management System are as follows:

- Provide a seamless and automated process for customers to place orders through social media channels

- Streamline the order management process from order collection to delivery tracking

- Improve stock management by automating stock checks and restocking requests

- Ensure accurate pricing information for each item

- Generate professional and customizable invoices for customers

- Enhance customer satisfaction through order and delivery tracking

- Send timely reminders to customers for pending orders and payments


4. Details of Modules:

The Online Social Media Order Management System consists of the following modules:

a) Order Collection Module: Receives orders from customers through social media channels and stores them in the system.

b) Stock Management Module: Manages the stock availability of each item and sends restocking requests to suppliers when necessary.

c) Pricing Module: Retrieves the latest price details for each item from a pricing database.

d) Invoice Generation Module: Generates invoices for customers, including item details, prices, and payment information.

e) Order Tracking Module: Tracks the status of each order from placement to delivery.

f) Delivery Tracking Module: Tracks delivery details, including shipping information and estimated delivery dates.

g) Reminder Module: Sends automated reminders to customers regarding their pending orders and payments.


5. Details of Classes:

The Online Social Media Order Management System consists of the following classes:

a) Customer: Represents a customer who places an order. Contains attributes such as name, contact details, and order history.

b) Order: Represents an individual order placed by a customer. Contains attributes such as order ID, order date, and order status.

c) Item: Represents an item available for purchase. Contains attributes such as item ID, item name, and item price.

d) Stock: Represents the stock availability of each item. Contains attributes such as item ID and quantity.

e) Supplier: Represents a supplier from whom the business purchases items. Contains attributes such as supplier ID and supplier contact details.

f) Invoice: Represents an invoice generated for a customer. Contains attributes such as invoice number, invoice date, and payment status.

g) Delivery: Represents the delivery details of an order. Contains attributes such as delivery ID, shipping information, and delivery status.


6. Details of Database Tables:

The Online Social Media Order Management System utilizes the following database tables:

a) Customers Table: Stores customer details, including customer ID, name, contact details, and order history.

b) Orders Table: Stores order details, including order ID, customer ID, order date, and order status.

c) Items Table: Stores item details, including item ID, item name, and item price

d) Stock Table: Stores stock details, including item ID and quantity.

e) Suppliers Table: Stores supplier details, including supplier ID and contact information.

f) Invoices Table: Stores invoice details, including invoice number, customer ID, invoice date, and payment status.

g) Delivery Table: Stores delivery details, including delivery ID, order ID, shipping information, and delivery status.


By implementing the Online Social Media Order Management System, the business will be able to automate and streamline its order management process, ensuring a seamless experience for customers. This system will not only save time and effort but also improve customer satisfaction and enable efficient tracking of orders and deliveries.


For more guidance on Projects !!!

Online Individual / Group classes in English / Sinhala / Tamil. Sample Projects/Assignments Exam Papers, Tutorials, Notes and Answers & more ..

CALL +94 777 33 7279 | EMAIL  ITCLASSSL@GMAIL.COM

Monday, June 26, 2023

Library Management System Project Proposal Scope Objective Feasibility Study Similar Systems Features Comparison Proposed System Features Non-Functional Functional Requirements Use Cases School University

 Project Proposal: Library Management System

Sample Project

Scope:

- The scope of this project is to develop a comprehensive Library Management System (LMS) that automates various library operations, such as book cataloging, circulation, member management, and reporting.

- The system will be designed to cater to the needs of both small and large libraries, including educational institutions, public libraries, and corporate libraries.

- The LMS will streamline the entire library workflow, enhancing the efficiency of library staff and improving the overall user experience for library patrons.


Objective:

- The main objective of the Library Management System is to provide a centralized platform for managing library resources, simplifying administrative tasks, and improving access to information for library users.

- The system aims to automate manual processes, reduce errors, and enhance productivity in library operations.

- Additionally, the LMS will facilitate easy retrieval of information, enable effective resource utilization, and provide valuable insights through reporting and analytics.


Feasibility Study:

- A feasibility study will be conducted to evaluate the viability and practicality of implementing the Library Management System.

- The study will assess the technical, economic, operational, and scheduling feasibility of the project.

- It will also consider factors such as resource availability, potential risks, and stakeholder requirements.


Similar Systems Features Comparison:

- A comparative analysis will be conducted to evaluate existing library management systems in terms of their features, functionalities, and user experience.

- The comparison will identify the strengths and weaknesses of each system and help in designing a superior LMS.

- Key aspects for comparison include book cataloging, circulation management, member management, reporting capabilities, scalability, and user interface.


Proposed System Features:

- Book Cataloging: Ability to add, edit, and categorize books with details such as title, author, ISBN, publication date, and genre.

- Circulation Management: Tracking book checkouts, reservations, due dates, and fines. Generating automated reminders and notifications.

- Member Management: Creating and managing member profiles, issuing library cards, tracking borrowing history, and facilitating member communication.

- Search and Retrieval: Powerful search functionality to locate books based on various criteria such as title, author, keywords, or genre.

- Reporting and Analytics: Generating comprehensive reports on book circulation, member statistics, popular titles, and overdue items.

- Integration with Online Databases: Seamless integration with external databases to retrieve book information, cover images, and additional metadata.

- Multi-user Accessibility: Support for multiple user roles, including librarians, administrators, and patrons, with appropriate access rights.

- Online Reservation and Renewal: Allowing users to reserve books online and renew borrowed items without physical visits to the library.


Functional Requirements:

- User Registration: Users should be able to create accounts and access the LMS.

- Book Cataloging: Librarians should be able to add, edit, and delete book records.

- Circulation Management: Tracking book checkouts, returns, and reservations.

- Member Management: Maintaining member records and issuing library cards.

- Reporting: Generating reports on book circulation, overdue items, and member statistics.

- Search Functionality: Allowing users to search for books based on various criteria.

- Online Reservation and Renewal: Enabling users to reserve books and renew borrowed items online.


Non-Functional Requirements:

- Security: Implementing robust security measures to protect user data and prevent unauthorized access.

- Performance: Ensuring the system performs efficiently, even with a large volume of data and concurrent users.

- Scalability: Designing the system to handle future growth in terms of data volume and user base.

- User-Friendly Interface: Creating an intuitive and easy-to-navigate user interface for both librarians and patrons.

- Accessibility: Ensuring the system is accessible to users with disabilities, adhering to accessibility guidelines.


Use Cases:

1. User Registration


: A new user creates an account by providing personal details and receives login credentials.

2. Book Checkout: A librarian scans a member's library card and books to be borrowed, updating the system accordingly.

3. Book Reservation: A patron searches for a book, places a reservation, and receives a notification when the book becomes available.

4. Book Renewal: A user logs in, selects the borrowed books for renewal, and extends the due dates if no reservations are pending.

5. Reporting: A librarian generates a report on the most borrowed books in a specific time period.


Technology:

- Programming Language: Python

- Web Framework: Django

- Database: PostgreSQL

- Front-end: HTML5, CSS3, JavaScript

- APIs: Integration with external book databases and services (e.g., ISBNdb, OpenLibrary)

- Security: Encryption, secure authentication mechanisms

- Hosting: Deployment on a cloud platform like Amazon Web Services (AWS) or Microsoft Azure


Note: This project proposal provides an outline for a Library Management System. Detailed specifications, workflows, and timelines will be developed in collaboration with stakeholders during the project initiation phase.


For more guidance on Projects !!!

Online Individual / Group classes in English / Sinhala / Tamil. Sample Projects/Assignments Exam Papers, Tutorials, Notes and Answers & more ..

CALL +94 777 33 7279 | EMAIL  ITCLASSSL@GMAIL.COM

Wednesday, June 21, 2023

How to Install Flask in Windows Python3 Setup VS Code virtual environment follow these simple basic steps for beginners

To install Flask on Windows in a virtual environment, you can follow these steps:

1. Install Python: Visit the official Python website at https://www.python.org/downloads/ and download the latest version of Python 3.x for Windows. Run the installer and make sure to check the box that says "Add Python to PATH" during the installation process.

2. Open a command prompt: Press `Win + R` on your keyboard, type `cmd`, and hit Enter. This will open a command prompt.

3. Create a virtual environment: In the command prompt, navigate to the directory where you want to create your virtual environment. Use the `cd` command to change directories. For example, if you want to create a virtual environment in a folder named "myproject," you can use the following command:

   cd C:\path\to\myproject

     Once you are in the desired directory, create the virtual environment by running the following command:

   python -m venv myenv

   This will create a virtual environment named "myenv" in the current directory.

4. Activate the virtual environment: To activate the virtual environment, run the following command:

   myenv\Scripts\activate

   You will notice that the command prompt changes to show the name of your virtual environment.

5. Install Flask: With the virtual environment activated, you can now install Flask. Run the following command:

   pip install flask

   This will download and install Flask and its dependencies.

6. Verify the installation: Once the installation is complete, you can verify that Flask is installed correctly. Run the following command:

   python -c "import flask; print(flask.__version__)"

   If Flask is installed properly, you should see the version number printed in the command prompt.

That's it! Flask should now be installed in your virtual environment on Windows. You can start building your Flask applications by writing your Python code in a file with a `.py` extension and running it using the `python` command within the virtual environment. Remember to activate the virtual environment each time you work on your Flask project by running the activation command mentioned in step 4.


To install Flask on Windows without a virtual environment, you can follow these steps:

If you're receiving a `ModuleNotFoundError` for the 'flask' module, it means that Flask is not installed in your Python environment. To resolve this issue, you can follow these steps:

1. Ensure you have Python installed: Verify that Python is installed on your system by opening a command prompt and running the command `python --version`. If Python is installed, it will display the version number. If not, download and install Python from the official website: https://www.python.org/downloads/

2. Install Flask: Open a command prompt and run the following command to install Flask using pip:

   pip install flask

   Make sure to run this command with administrative privileges if required. Pip is a package manager for Python, and it will download and install Flask and its dependencies.

3. Verify the installation: After the installation completes, you can verify if Flask is installed correctly. In the command prompt, run the following command:

   python -c "import flask; print(flask.__version__)"

   If Flask is installed properly, it should print the version number without any errors.

Once Flask is successfully installed, you should be able to run your Flask application without encountering the `ModuleNotFoundError`.


Here's a simple "Hello, World!" example using Flask in Python:


from flask import Flask

# Create a Flask application
app = Flask(__name__)

# Define a route and its corresponding function
@app.route('/')
def hello_world():
    return 'Hello, World!'

# Run the Flask application
if __name__ == '__main__':
    app.run()


Save the above code in a file with a `.py` extension, such as `app.py`. Make sure you have Flask installed in your Python environment as described in the previous instructions. Then, you can run the script from the command line using `python app.py`.

The Flask application creates an instance of the Flask class and defines a single route `'/'` using the `@app.route` decorator. The function `hello_world()` is associated with this route and returns the string `'Hello, World!'`.

When you run the script, the Flask development server starts, and you can access the application by visiting `http://localhost:5000` in your web browser. The page should display "Hello, World!" as the response.

Remember to stop the server by pressing `Ctrl+C` in the command prompt when you're done testing the application.


 * Serving Flask app 'app'

 * Debug mode: off

WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

 * Running on http://127.0.0.1:5000

Press CTRL+C to quit

127.0.0.1 - - [21/Jun/2023 11:49:15] "GET / HTTP/1.1" 200 -

127.0.0.1 - - [21/Jun/2023 11:49:15] "GET /favicon.ico HTTP/1.1" 404 -


The Debug mode is enabled by setting the debug property of the application object to True before running or passing the debug parameter to the run() method.

app.debug = True

app.run()

app.run(debug = True)


route() decorator in Flask is used to bind URL to a function. For example −

@app.route(‘/hello’)
def hello_world():
   return hello world


The add_url_rule() function of an application object is also available to bind a URL with a function as in the above example, route() is used.

A decorator’s purpose is also served by the following representation −

def hello_world():
   return hello world
app.add_url_rule(‘/’, hello’, hello_world)


In the following example, the rule parameter of route() decorator contains <name> variable part attached to URL ‘/hello’. Hence, if the http://localhost:5000/hello/ITClass is entered as a URL in the browser, ‘ITClass’ will be supplied to hello() function as argument.

from flask import Flask
app = Flask(__name__)

@app.route('/hello/<name>')
def hello_name(name):
   return 'Hello %s!' % name

if __name__ == '__main__':
   app.run(debug = True)

Save the above script as hello.py and run it from Python shell. Next, open the browser and enter URL http://localhost:5000/hello/ITClass.

The following output will be displayed in the browser.

Hello ITClass!


In addition to the default string variable part, rules can be constructed using the following converters −

Sr.No.Converters & Description
1

int   accepts integer

2

float  For floating point value

3

path   accepts slashes used as directory separator character

In the following code, all these constructors are used.

from flask import Flask
app = Flask(__name__)

@app.route('/blog/<int:postID>')
def show_blog(postID):
   return 'Blog Number %d' % postID

@app.route('/rev/<float:revNo>')
def revision(revNo):
   return 'Revision Number %f' % revNo

if __name__ == '__main__':
   app.run()


The url_for() function is very useful for dynamically building a URL for a specific function. The function accepts the name of a function as first argument, and one or more keyword arguments, each corresponding to the variable part of URL.

The following script demonstrates use of url_for() function.

from flask import Flask, redirect, url_for
app = Flask(__name__)

@app.route('/admin')
def hello_admin():
   return 'Hello Admin'

@app.route('/guest/<guest>')
def hello_guest(guest):
   return 'Hello %s as Guest' % guest

@app.route('/user/<name>')
def hello_user(name):
   if name =='admin':
      return redirect(url_for('hello_admin'))
   else:
      return redirect(url_for('hello_guest',guest = name))

if __name__ == '__main__':
   app.run(debug = True)

Http protocol is the foundation of data communication in world wide web. Different methods of data retrieval from specified URL are defined in this protocol.

The following table summarizes different http methods −

Sr.No.Methods & Description
1

GET

Sends data in unencrypted form to the server. Most common method.

2

HEAD

Same as GET, but without response body

3

POST

Used to send HTML form data to server. Data received by POST method is not cached by server.

4

PUT

Replaces all current representations of the target resource with the uploaded content.

5

DELETE

Removes all current representations of the target resource given by a URL

By default, the Flask route responds to the GET requests. However, this preference can be altered by providing methods argument to route() decorator.

In order to demonstrate the use of POST method in URL routing, first let us create an HTML form and use the POST method to send form data to a URL.

Save the following script as login.html

<html>
   <body>
      <form action = "http://localhost:5000/login" method = "post">
         <p>Enter Name:</p>
         <p><input type = "text" name = "nm" /></p>
         <p><input type = "submit" value = "submit" /></p>
      </form>
   </body>
</html>

Now enter the following script in Python shell.

from flask import Flask, redirect, url_for, request
app = Flask(__name__)

@app.route('/success/<name>')
def success(name):
   return 'welcome %s' % name

@app.route('/login',methods = ['POST', 'GET'])
def login():
   if request.method == 'POST':
      user = request.form['nm']
      return redirect(url_for('success',name = user))
   else:
      user = request.args.get('nm')
      return redirect(url_for('success',name = user))

if __name__ == '__main__':
   app.run(debug = True)

After the development server starts running, open login.html in the browser, enter name in the text field and click Submit.



Flask will try to find the HTML file in the templates folder, in the same folder in which this script is present.

  • Application folder
    • Hello.py
    • templates
      • hello.html

The term ‘web templating system’ refers to designing an HTML script in which the variable data can be inserted dynamically. A web template system comprises of a template engine, some kind of data source and a template processor.

The following code is saved as hello.html in the templates folder.

<!doctype html>
<html>
   <body>
   
      <h1>Hello {{ name }}!</h1>
      
   </body>
</html>

Next, run the following script from Python shell.

from flask import Flask, render_template
app = Flask(__name__)

@app.route('/hello/<user>')
def hello_name(user):
   return render_template('hello.html', name = user)

if __name__ == '__main__':
   app.run(debug = True)

As the development server starts running, open the browser and enter URL as − http://localhost:5000/hello/mvl

The variable part of URL is inserted at {{ name }} place holder.

The jinja2 template engine uses the following delimiters for escaping from HTML.

  • {% ... %} for Statements
  • {{ ... }} for Expressions to print to the template output
  • {# ... #} for Comments not included in the template output
  • # ... ## for Line Statements

The Python Script is as follows −

from flask import Flask, render_template
app = Flask(__name__)

@app.route('/hello/<int:score>')
def hello_name(score):
   return render_template('hello.html', marks = score)

if __name__ == '__main__':
   app.run(debug = True)

HTML template script of hello.html is as follows −

<!doctype html>
<html>
   <body>
      {% if marks>50 %}
         <h1> Your result is pass!</h1>
      {% else %}
         <h1>Your result is fail</h1>
      {% endif %}
   </body>
</html>

Note that the conditional statements if-else and endif are enclosed in delimiter {%..%}.


from static folder in your package or next to your module and it will be available at /static on the application.

A special endpoint ‘static’ is used to generate URL for static files.

In the following example, a javascript function defined in hello.js is called on OnClick event of HTML button in index.html, which is rendered on ‘/’ URL of the Flask application.

from flask import Flask, render_template
app = Flask(__name__)

@app.route("/")
def index():
   return render_template("index.html")

if __name__ == '__main__':
   app.run(debug = True)

The HTML script of index.html is given below.

<html>
   <head>
      <script type = "text/javascript" 
         src = "{{ url_for('static', filename = 'hello.js') }}" ></script>
   </head>
   
   <body>
      <input type = "button" onclick = "sayHello()" value = "Say Hello" />
   </body>
</html>

hello.js contains sayHello() function.

function sayHello() {
   alert("Hello World")
}
  • Form − It is a dictionary object containing key and value pairs of form parameters and their values.

  • args − parsed contents of query string which is part of URL after question mark (?).

  • Cookies − dictionary object holding Cookie names and values.

  • files − data pertaining to uploaded file.

  • method − current request method.

-------------------------------

In the following example, ‘/’ URL renders a web page (student.html) which has a form. The data filled in it is posted to the ‘/result’ URL which triggers the result() function.

The results() function collects form data present in request.form in a dictionary object and sends it for rendering to result.html.

The template dynamically renders an HTML table of form data.

Given below is the Python code of application −

from flask import Flask, render_template, request
app = Flask(__name__)

@app.route('/')
def student():
   return render_template('student.html')

@app.route('/result',methods = ['POST', 'GET'])
def result():
   if request.method == 'POST':
      result = request.form
      return render_template("result.html",result = result)

if __name__ == '__main__':
   app.run(debug = True)

Given below is the HTML script of student.html.

<html>
   <body>
      <form action = "http://localhost:5000/result" method = "POST">
         <p>Name <input type = "text" name = "Name" /></p>
         <p>Physics <input type = "text" name = "Physics" /></p>
         <p>Chemistry <input type = "text" name = "chemistry" /></p>
         <p>Maths <input type ="text" name = "Mathematics" /></p>
         <p><input type = "submit" value = "submit" /></p>
      </form>
   </body>
</html>

Code of template (result.html) is given below −

<!doctype html>
<html>
   <body>
      <table border = 1>
         {% for key, value in result.items() %}
            <tr>
               <th> {{ key }} </th>
               <td> {{ value }} </td>
            </tr>
         {% endfor %}
      </table>
   </body>
</html>

Run the Python script and enter the URL http://localhost:5000/ in the browser

------



More ref https://www.tutorialspoint.com/flask/

For more guidance on Projects !!!

Online Individual / Group classes in English / Sinhala / Tamil. Sample Projects/Assignments Exam Papers, Tutorials, Notes and Answers & more ..

CALL +94 777 33 7279 | EMAIL  ITCLASSSL@GMAIL.COM