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

Generate a modest Web page via Python flask. It should include basic components of HTML. The...
Generate a modest Web page via Python flask. It should include basic components of HTML. The Web page should have at least three Headings(<h1>), a paragraph (<p>), comments (<!-- -->), ordered list, unordered list, three links to website, and should display time & date.
Using Python programming, make a form that allows user to login to a modest web application...
Using Python programming, make a form that allows user to login to a modest web application that has a password and username with a file that has validated user. Once logged in, a formal greeting and the choice to change password should be available. The password should be strong(NIST SP 800-63B). All failed logins should be logged w/ date and Time. (Ex. 6 failed logins in 20 min dated 12 Jan 2020.
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...
Using HTML: Create a Book of the Month Club Web site. The home page should describe...
Using HTML: Create a Book of the Month Club Web site. The home page should describe the current month's selection, including book title, author, publisher, ISBN, and the number of pages. Create separate Web pages for book selections in each of the last three months. Add links to the home page that opens each of the three Web pages. Save the home page as BookClub.html, and save the Web Pages for previous months using the name of the month. BOOK:...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT