0

I'm not able to have the output displayed on the page. I've tried using app.send_static_file()

Is there anything, I'm missing in the code or the HTML Page ..?

enter image description here

I've updated the code a bit and checked with the HTTP toolkit the response is an HTML file but it's not showing up on the page.

enter image description here

Python

@app.route("/", methods=['GET','POST'])
def main_page():
    if request.method == "POST":
        submitted = request.form.to_dict()
        print(submitted)
        if submitted["authorizationcode"] == "RandomNO":
            if len(submitted["ktownurl"]) >0:
                print("Not Null")
            else:
                price = submitted["price"]
                price = float(price)
                productype = submitted["producttype"]
                bulorder = submitted["bulkorder"]
                calc_prices = calculator(price,bulorder,productype)
                calculated = calc_prices.split(":")
                minretail = calculated[0]
                maxretail = calculated[1]
        return(render_template("index.html", minretail=minretail, maxretail = maxretail))
    else:
        return(render_template("index.html"))


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=80)

HTML

    <section class="u-clearfix u-valign-middle u-section-2" id="sec-fb20">
      <div class="u-clearfix u-expanded-width u-layout-wrap u-palette-5-dark-2 u-layout-wrap-1">
        <div class="u-layout">
          <div class="u-layout-row">
            <div class="u-container-style u-layout-cell u-size-30 u-layout-cell-1">
              <div class="u-container-layout u-container-layout-1">
                <h3 class="u-align-center u-text u-text-1">Minimu​​m Price</h3>
                <div class="u-container-style u-group u-palette-1-base u-radius-15 u-shape-round u-group-1">
                  <div class="u-container-layout u-container-layout-2">
                    <h4 class="u-align-center u-text u-text-default u-text-2">{{minretail}}</h4>
Tim Perry
  • 11,766
  • 1
  • 57
  • 85
KABOOM
  • 45
  • 9
  • 1
    Are you seeing those blanks after making a POST request? If you're just "GET"ting the page you wouldn't have values for `minretail` or `maxretail`. To test this you can change the line `return(render_template("index.html"))` to `return(render_template("index.html", minretail=0, maxretail=1))`. If you see a 0 and 1, that means you're making the wrong request type/your route needs to be tweaked. – AC1009 Nov 11 '21 at 16:02
  • Yeah, I'm getting those blanks after the POST request., and I tried return(render_template()"index.html", minretail = 0 , maxretail = 0) and even they didn't show up. – KABOOM Nov 11 '21 at 16:05
  • Bummer. I can only see the snippet of HTML you included, but you're sure that the HTML structure is OK? And also you're sure that the text isn't the same color as the background? – AC1009 Nov 11 '21 at 16:07
  • I can upload it to github – KABOOM Nov 11 '21 at 16:10
  • I'm getting the POST request properly i can see that in the console, It's only not outputting in the HTML file for some reason – KABOOM Nov 11 '21 at 16:12
  • Is the `h4` element there when you inspect it? Or is just the empty `u-container-layout` `div`? – AC1009 Nov 11 '21 at 16:13
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/239149/discussion-between-kaboom-and-ac1009). – KABOOM Nov 12 '21 at 08:48

0 Answers0