Rafael Rafael - 5 months ago 29
Python Question

Simple Flask Application Not Working

I trained a machine learning model which I wanted to deploy as an app. I learnt that flask is especially suited for this.

I have two functions, get_data from the user of the web app and then, infer_results which prints the results of image type.

I am trying to set up flask for the above use case. I started by following this tutorial: https://sourcedexter.com/python-rest-api-flask/

What I did:

In [71]: app = Flask(__name__)

In [72]: @app.route("/me", methods=["GET"])
...: def get_results():
...: return "Dummy Result"

And then,

In [73]: app.run(host="", threaded=True)
* Running on (Press CTRL+C to quit)

But all I get is:

enter image description here

I can't figure out what is going wrong? This is my main question.

On a sidenote, it would be really great if you could offer some advice or suggestion on : how should I go about building my app: I want to do in Python only. But then, how should I design the UI: where user can put his data and upload it? Is there a way to package all my code (the machine learning code + the user input/output) in a desktop application that user can download and run on his PC?

Answer Source

Instead of app.run(host="", threaded=True)


app.run(host="localhost", threaded=True)

Or Execute the below script:

from flask import Flask, render_template

app = Flask(__name__)

# index
def index():
    return "Hello"

# /me    
@app.route("/me", methods=["GET"])
def get_results():
    return "Dummy Result"

if __name__ == "__main__":
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download