0

Here is the code of my application I am trying to run:

from flask import Flask, request, render_template
import json
import requests
import socket
from datetime import datetime
import pickle
import time
import pandas as pd
import numpy as np
@app.route('/index.html')
def index():
    return render_template('index.html')

@app.route('/tables.html')
def tables():
    return render_template('tables.html')

@app.route('/flot.html')
def flot():
    return render_template('flot.html')

@app.route('/morris.html')
def morris():
    return render_template('morris.html')

@app.route('/forms.html')
def forms():
    return render_template('forms.html')

@app.route('/panels-wells.html')
def panelswells():
    return render_template('panels-wells.html')

@app.route('/buttons.html')
def buttons():
    return render_template('buttons.html')

@app.route('/notifications.html')
def notifications():
    return render_template('notifications.html')

@app.route('/typography.html')
def typography():
    return render_template('typography.html')

@app.route('/icons.html')
def icons():
    return render_template('icons.html')

@app.route('/blank.html')
def blank():
    return render_template('blank.html')


@app.route('/login.html')
def login():
    return render_template('login.html')

if __name__ == '__main__':

    app.run(host='0.0.0.0', port=8080, debug=True, threaded=True)
    pass

Here is how I ran it:

C:\Users\aims\Desktop\forex>python forex_app.py
 * Serving Flask app "forex_app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 122-288-656
 * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
 * Detected change in 'C:\\Users\\aims\\Desktop\\forex\\forex_app.py', reloading
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 122-288-656

After hitting the url as: http://0.0.0.0:8080 or even http://0.0.0.0:8080/index.html I see the following screen:
output image

Kindly, help me what I am missing. I have the html templates available in the templates folder. See the image:
folder images

Please let me know.

2 Answers 2

1

There are a number of things wrong here.

0.0.0.0 is not an address you put into the browser; it's a special value to tell the server to bind to any address. You need to access the site via the localhost IP, which is 127.0.0.1:8080.

Secondly, you don't define a route handler in your Flask code for the root path; you only define "index.html", and so on. I suspect that you are misunderstanding what is going on there; the route is what you put into the browser, and it is not in any way related to the template you render. It is quite possible (and preferable) to define a route for / but for the handler to render "index.html":

@app.route('/')
def index():
    return render_template('index.html')
Sign up to request clarification or add additional context in comments.

Comments

1

try 127.0.0.1:8080, the 0.0.0.0:8080 just means the app is listening for all connections

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.