Question

In: Computer Science

Make a modest or simple Web page using Python flask. The basic components of HTML should...

Make a modest or simple Web page using Python flask. The basic components of HTML should be included. The Web page should have at least 3 Headings(<h1>), paragraph (<p>), comments (<!-- -->), ordered list, unordered list, three links to website, and should display time & date.

Example:

<html>

    <head>

        <title>Page Title</title>

    </head>

<body>

    ..new page content..

</body>

</html>

Solutions

Expert Solution

Code:

main.py

from flask import Flask,redirect,url_for,render_template

import datetime


app=Flask(__name__) #flask class object

@app.route('/') #to navigate from one page to another we use route function

#@ decorator

def index():

    x = datetime.datetime.now() # to get date and time

    return render_template('basic.html',date=x)

if __name__=='__main__':

    app.run(host="127.0.0.1",debug="True") #set your host number and debug == true

main.py code in image:

basic.html

<htm>

    <head>

        <title>Page Title</title>

    </head>

    <body>

        <!--Three headings-->

        <h1>THis is h1 heading</h1>

        <h2>THis is h2 heading</h2>

        <h3>THis is h3 heading</h3>

        

        <p>This is a Paragraph</p>

        <!-- This is order list -->

        <ol>

            <li>Coffee</li>

            <li>Tea</li>

            <li>Milk</li>

        </ol>

        <!-- This is unorder list -->

        <ul style="list-style-type:disc;">

            <li>Coffee</li>

            <li>Tea</li>

            <li>Milk</li>

        </ul>

        <!--{{date.year}} is used to print the current year from the date obtained in main.py, similarly month, day, hour,minute and second-->

        <p>Date: {{date.year}}-{{date.month}}-{{date.day}}</p>

        <p>Time: {{date.hour}}:{{date.minute}}:{{date.second}}</p>

        <!--Three links to website-->

        <a href="http://google.co.in">Link to google</a><br>

        <a href="http://google.co.in">Link to google</a><br>

        <a href="http://google.co.in">Link to google</a><br>

    </body>

</htm>

basic.html in image with comments:

Explanation:

The basic.html is rendered by the main.py file in the given server i.e(127.0.0.1 in our case).

The datetime library is imported in main.py file and the value is sent to basic.html.

basic.html file should be stored in templates folder of flask.

Output:


Related Solutions

Week 4 Assignment HTML – Creating a Simple Web Page “HTML or HyperText Markup Language as...
Week 4 Assignment HTML – Creating a Simple Web Page “HTML or HyperText Markup Language as it is formally known is the main markup language for creating web pages and other information that can be displayed in a webbrowser”. It was created by Tim Berners-Lee in 1989 as a user friendly way of sharing information on the Internet. http://en.wikipedia.org/wiki/HTML Assignment Instructions - Create a simple HTML Web Page that includes hyperlinks to three of your favorite websites. Use the online...
use CSS, java and HTML to make a charity admin page. It's a web page after...
use CSS, java and HTML to make a charity admin page. It's a web page after you log in to your account. I can have personal information, the amount of money donated, the children who have received charity, and some blogs. In fact, all the things are what I want. But you are free to do whatever You like, even if you don't say what I say. I just need a charity Admin page for charity User.Don't ask me for...
use CSS, java and HTML to make a charity admin page. It's a web page after...
use CSS, java and HTML to make a charity admin page. It's a web page after you log in to your account. I can have personal information, the amount of money donated, the children who have received charity, and some blogs. In fact, all the things are what I want. But you are free to do whatever You like, even if you don't say what I say. I just need a charity Admin page for charity User.Don't ask me for...
use CSS, java and HTML to make a charity admin page. It's a web page after...
use CSS, java and HTML to make a charity admin page. It's a web page after you log in to your account. I can have personal information, the amount of money donated, the children who have received charity, and some blogs. In fact, all the things are what I want. But you are free to do whatever You like, even if you don't say what I say. I just need a charity Admin page for charity User.Don't ask me for...
use CSS, java and HTML to make a charity admin page. It's a web page after...
use CSS, java and HTML to make a charity admin page. It's a web page after you log in to your account. I can have personal information, the amount of money donated, the children who have received charity, and some blogs. In fact, all the things are what I want. But you are free to do whatever You like, even if you don't say what I say. I just need a charity Admin page for charity User.Don't ask me for...
use CSS, java and HTML to make a charity admin page. It's a web page after...
use CSS, java and HTML to make a charity admin page. It's a web page after you log in to your account. I can have personal information, the amount of money donated, the children who have received charity, and some blogs. In fact, all the things are what I want. But you are free to do whatever You like, even if you don't say what I say. I just need a charity Admin page for charity User.Don't ask me for...
use CSS, java and HTML to make a charity admin page. It's a web page after...
use CSS, java and HTML to make a charity admin page. It's a web page after you log in to your account. I can have personal information, the amount of money donated, the children who have received charity, and some blogs. In fact, all the things are what I want. But you are free to do whatever You like, even if you don't say what I say. I just need a charity Admin page for charity User.Don't ask me for...
How do I make a simple TCP python web client and web server using only "import...
How do I make a simple TCP python web client and web server using only "import socket"? Basically, the client connects to the server, and sends a HTTP GET request for a specific file (like a text file, HTML page, jpeg, png etc), the server checks for the file and sends a copy of the data to the client along with the response headers (like 404 if not found, or 200 if okay etc). The process would be: You first...
Create a Web Page Using HTML, CSS, JS, jQuery • Create a web profile, including any...
Create a Web Page Using HTML, CSS, JS, jQuery • Create a web profile, including any of the following: • Your hobbies, likes/dislikes, career aspirations, dream job, favorite animals/ pets, favorite superhero, etc. • You do not have to share personal information that you are uncomfortable with sharing. Follow these guidelines when creating your page: • Include at least one heading (h1, h2, etc.) in your web page. • Provide a quote from a book, movie, etc. • Include at...
Create a web page that contains a simple math test. The page should have the following...
Create a web page that contains a simple math test. The page should have the following arithmetic problems. Add a button under each problem which, when clicked, will display a prompt for the user to enter the answer. Add a swcond button which, when clicked, will check to see if the user's answer is correct. The output should be either "correct" or "incorrect" displayed in an alert box. 1. 5+9= 2. 4*6= 3. 25-14= 4. 48/3= 5. 26%6=
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT