10 Replies - 663 Views - Last Post: 04 December 2019 - 12:46 PM Rate Topic: -----

#1 kam536   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 21-March 18

How to get html to work ?

Posted 30 November 2019 - 10:47 PM

from flask import Flask
app = Flask(__name__)
@app.route('/Wolves')
<!DOCTYPE html>
<html>
<head>
<title>Wolves<title>
</head>
<body>
<!--Introduces Wolves, provides some information-->
<h1>Wolves</h1>
<p>There are three wolf species in the world. The Grey Wolf, the Red Wolf, and 
the Ethiopian Wolf. As well as subspecies of the three main species, that are
named based on the region they inhabit. There are many similaries that are 
shared between these types of wolves but enough differences to seperate them and
as research continues the distinct differences become more visible</p>
<!--First Section contains some information about the Gray Wolves-->
<h2>Gray Wolf</h>
<p>The gray wold is also referred to as the timber wolf. In North America there
are between 5 to 24 subspecies recognized. In Eurasia there are 7 to 12 
subspecies.In Africa there is one subspecies recognized. A typical male can be
6.6 feet long, including their tail. They can stand 30 inches tall at the 
shoulder. Their weight can range anywhere from 31 to 143 pounds depending on the
area they live in. On average females are around 20 percent smaller that males
are. Fur color can be gray, brown, reddish, black or whitish, all with yellow-
white fur on the under parts. Fur color is dependent on location.</p>
<!--Second Section contains some information about Red Wolves-->
<h3>Red Wolf</h3>
<p>The most endanged member of the dog family.They are about 4 feet long and 
weigh between 45 to 80 pounds. Red wolves are native to the United States. They
have a tawny reddish coat. The grey wolf and coyote were interbred in the past
to produce the red wolves ancestors. So, they are intermediate in size between
the two species.There are only an estimated 35 or less wild red wolves that 
remain in the Alligator River National Wildlife Refuge in eastern North Carolina
and the surrounding countries. They are critically endanged.</p>
<!--Third Section contains information about Ethiopian Wolves-->
<h4>Ethiopian Wolf</h4>
<p>The Ethiopian wolf is found in six or seven mountain ranges of Ethiopian.They
are long-limbed and slender looking. They have a reddish coat with white 
markings on the legs, underbelly, tail, face, and chin.The boundries between
the red and white are quite distinct. They have a characteristic white cresents
below their eyes and white spots on their cheeks. There are black stripes down
its tail and black hairs on the tip. Females are usually smaller and paler in 
color than the males.Ethiopian wolves have 5 toes on the front feet and 4 toes
on the rear feet. They can weigh between 24 to 43 pounds and are between 33 to
40 inches long</p>
<!--Contains information about animals related to wolves-->
<h5>Canidae Family</5>
<p>The Canidae Family is one of the oldest groups of carnivores still in
exsistence. The Qualities found throughout the Canidae family include deep-
chested bodies with elongated muzzles, physical endurance and an acute sense of
smell and hearing. Some of the members include:</p>
<ol>
<li>Wolves</li>
<li>Dogs</li>
<li>Foxes</li>
<li>Coyotes</li>
<li>Jackals</li>
</ol>
<!--General Characteristics of Wolves-->
<h6>General Characteristics of Wolves</h6>
<p>Wolves have developed the capacity to survive in the most inhospital of 
climates.There are many characteristics that make up wolves and some of those
include:</p>
<ul>
<li>Very intelligent creatures</li>
<li>Upright ears</li>
<li>Sharp teeth</li>
<li>Pointed Muzzle</li>
<li>Inquiring eyes</li>
<li>Height varies from 26 to 38 inches at the shoulders</li>
<li>Weight varies from 22 to 175 pounds</li>
<li>Bodies built for stamina</li>
<li>Posses features ideal for long distance travel</li>
<li>Narrow Chests</li>
<li>Powerful backs and legs</li>
<li>And many more</li>
</ul>
<p>"<em><a href = "wolfworlds.com/wolf-species/">Wolf Species</a></em>"webpage
has more information on the Wolf species.</p>
<p>"<em><a href = "britannica.com/animal/gray-wolf">Gray Wolf</a></em>"webpage 
has more information on the Gray Wolf.</p>
<p>"<em><a href = "nationalgeographic.com/animal/mammals/r/red-wolf/">Red Wolves
</a></em>"webpage has more information about Red Wolves.</p>
<p>"<em><w href ="animaldiversity.org/accounts/canis_simensis/">Ethiopian Wolf
</a></em>"webpage has more information on the Ethiopian Wolf.</p>
<p>"</em><a href = "animals.mom.me/animals-part-wolf-family-5278.html">Animals
that are a part of the wolf family</a></em>"webpage has more information on the
animals that are in the same family as wolves.</p>
<p>"<em><a href = "animalcorner.co.uk/animals/wolves/">Wolves</a></em>" webpage
has more information about the characteristics of Wolves.</p>
</body>
</html>

app.run(host ='0.0.0.0', port = 8080)




This is what I'm getting when I try to run the program:
File "/home/ec2-user/environment/Project6/Python Web Page Code.py", line 10
<!DOCTYPE html>
^
SyntaxError: invalid syntax

Why is it invalid syntax? What am I missing?

Is This A Good Question/Topic? 0
  • +

Replies To: How to get html to work ?

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6833
  • View blog
  • Posts: 28,341
  • Joined: 12-December 12

Re: How to get html to work ?

Posted 01 December 2019 - 05:47 AM

That won't work because it is a Python file with some HTML thrown into it. You need some method to generate HTML output.

What tutorial are you following?
Was This Post Helpful? 0
  • +
  • -

#3 kam536   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 21-March 18

Re: How to get html to work ?

Posted 01 December 2019 - 05:01 PM

Its some book our teacher gave us to follow, in the book it doesn't give us more than what I have in the file above.

This post has been edited by andrewsw: 02 December 2019 - 01:22 AM
Reason for edit:: removed unnecessary previous quote, use the Reply button

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6833
  • View blog
  • Posts: 28,341
  • Joined: 12-December 12

Re: How to get html to work ?

Posted 02 December 2019 - 01:24 AM

I find it had to fathom that the book would be so flawed. In which case, search something like "python flask tutorial" to find an alternative, decent, resource. There will be loads of introductory tutorials, for example this one.

It includes a basic code example such as

from app import app

@app.route('/')
@app.route('/index')
def index():
    return "Hello, World!"

Was This Post Helpful? 0
  • +
  • -

#5 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 3062
  • View blog
  • Posts: 11,753
  • Joined: 03-December 12

Re: How to get html to work ?

Posted 02 December 2019 - 08:07 AM

You are putting html IN the python code, which obviously is a problem. I don't think that's specifically what's in the book.

What book were you given? And did you read it carefully? That is something that should obviously be in the errata, if that is what it says.
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6839
  • View blog
  • Posts: 31,513
  • Joined: 10-May 07

Re: How to get html to work ?

Posted 02 December 2019 - 09:52 AM

View Postkam536, on 01 December 2019 - 01:47 AM, said:

This is what I'm getting when I try to run the program:
File "/home/ec2-user/environment/Project6/Python Web Page Code.py", line 10
<!DOCTYPE html>
^
SyntaxError: invalid syntax

Why is it invalid syntax? What am I missing?

From the code provided, the html starts at line 4, not line 10. There is nothing calling that text, so it is in fact invalid python syntax. Line 4 starts with html. What is python expected to do with this?
Was This Post Helpful? 0
  • +
  • -

#7 Histiogge   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 03-December 19

Re: How to get html to work ?

Posted 03 December 2019 - 01:44 AM

Actually, it's totally fine that you get an error when trying to run this code. It won't work as the HTML you have you inserted right into the Python code. Are you sure that the book author meant doing this very thing? And can you tell the name of the book or share the extract with this example/task? Cause it looks really suspicious to me at the moment
Was This Post Helpful? 0
  • +
  • -

#8 kam536   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 21-March 18

Re: How to get html to work ?

Posted 04 December 2019 - 12:01 PM

View Postastonecipher, on 02 December 2019 - 08:07 AM, said:

You are putting html IN the python code, which obviously is a problem. I don't think that's specifically what's in the book.

What book were you given? And did you read it carefully? That is something that should obviously be in the errata, if that is what it says.



He just gave us a link to HTML with no explanation on how to implement it in Python. We were supposed to use Flask in Python but he didn't provide any other information other than a book on HTML. So I am confused about how to implement using Flask in Python I guess?

I have been emailing him and other students in my class but haven't heard anything back yet.
Was This Post Helpful? 0
  • +
  • -

#9 kam536   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 21-March 18

Re: How to get html to work ?

Posted 04 December 2019 - 12:10 PM

View PostHistiogge, on 03 December 2019 - 01:44 AM, said:

Actually, it's totally fine that you get an error when trying to run this code. It won't work as the HTML you have you inserted right into the Python code. Are you sure that the book author meant doing this very thing? And can you tell the name of the book or share the extract with this example/task? Cause it looks really suspicious to me at the moment


This is what the assignment is:

Python Applications for Lab6: (total 100 points):
This exercise (80 points) uses the AWS Cloud9 environment to generate a simple Web page using
Python flask. The Web page should include all basic components of the HTML structure including:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
...your page content...
</body>
</html>
In addition to the basic HTML structure components listed above, your web page should demonstrate
and include the following HTML tags and functionality:
 At least 3 different Headings (e.g. <h1>, <h2>, <h3>)
 Paragraph (<p>)
 Comments <!-- -->)
 Ordered list
2
 Unordered list
 At least 3 Links to other External Web Sites
 Display the Date and Time on the Web page (Hint: Just use the Python date/time functions to
display in HTML)
The content and topic of the Web site is up to you. It should be unique and something you want to
create.
Hints:
1. Be sure to end tags that are started (e.g. <h1> </h1>)
2. Start early. This will take you longer than you think.
3. Be sure to send me questions, if you need assistance.
2. Document your results of the application running from the AWS Cloud9 classroom environment.
Provide screen captures and descriptions of you running the Python application within AWS Cloud9
verifying you successfully started and have navigated to your Web application using your Browser. Show
screen captures of your Web application running on the Browser. 20 points)


This is the book we were supposed to refer to for help:

Sams Teach Yourself HTML, CSS & Javascript Web Publishing in One Hour a Day, Covering HTML5, CSS3, and jQuery, Seventh Edition
by Jennifer Kyrnin, Rafe Colburn, Laura Lemay
Publisher: Sams
Release Date: December 2015
ISBN: 9780133132397


So with what I posted for the code, I got a 90% but I'm not understanding how to use the Flask in Python to actually get the webpage to display!

View Postandrewsw, on 02 December 2019 - 01:24 AM, said:

I find it had to fathom that the book would be so flawed. In which case, search something like "python flask tutorial" to find an alternative, decent, resource. There will be loads of introductory tutorials, for example this one.

It includes a basic code example such as

from app import app

@app.route('/')
@app.route('/index')
def index():
    return "Hello, World!"


Thank you, I will take a look at this here soon.
Was This Post Helpful? 0
  • +
  • -

#10 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 3062
  • View blog
  • Posts: 11,753
  • Joined: 03-December 12

Re: How to get html to work ?

Posted 04 December 2019 - 12:28 PM

Have you looked at any of the basic tutorials on flask?
Was This Post Helpful? 0
  • +
  • -

#11 kam536   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 21-March 18

Re: How to get html to work ?

Posted 04 December 2019 - 12:46 PM

View Postastonecipher, on 04 December 2019 - 12:28 PM, said:

Have you looked at any of the basic tutorials on flask?


I am currently reading the one provided by one of the individuals above and seeing how it goes from there.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1