I have the image files uploaded to my cloud9 IDE, the code only spits out the text added to go with the images, but won't show the images. How can I set it up so that the images will show?
I have tried looking at code online for HTML that do a similar function but none of them have been working in my situation. I am not using a static file in this process, The process I need to follow requires me to build the html code into the python code itself. As the code shows, it needs to be accessible in cloud9 IDE and I don't have access to the template folder where Flask would look for static templates for HTML code. This is a different issue.
#import statements
import os
from flask import Flask
app = Flask(__name__)
@app.route("/")
@app.route('/moreHTML')
def hello_index():
my_reply = pop_head()
my_reply += "<p></p>"
my_reply += pictures()
return my_reply
def pictures():
"""inserts photos into website via HTML"""
photo = "<!DOCTYPE html> "
photo += '<img src="1.jpg" alt="Flying Kites" width="300" height="300"> '
photo += '<br>'
photo += 'alt="A funny dog sitting on the grass.">'
return photo
def popEnd():#
"""Ends the HTML code"""
end_data = "</body>"
end_data += "</html>"
return end_data
def pop_head():
"""puts together the website title"""
head_data = "<!DOCTYPE html> "
head_data += "<head> "
head_data += "<title>A Website</title>"
head_data += "<style>" + getStyle() + "</style>"
head_data += "</head>"
head_data += "<body>"
return head_data
def getStyle():
"""puts together the style used in website title"""
my_style = "table,td {"
my_style += "border: 12px solid #130;"
my_style += "}"
return my_style
host = '0.0.0.0'
if __name__ == '__main__':
app.debug = True
port = int(os.environ.get("PORT", 8080))
app.run(host=host, port=port)