Forums

Flask doesn't work

.

import random
from flask import Flask
from flask_restful import Api, Resource

app = Flask(__name__)
api = Api(app)

class HelloWorld(Resource):
    def get(self):
        return {'hello': 'world'}

api.add_resource(HelloWorld, '/')

if __name__ == '__main__':
    port = 5000 + random.randint(0, 999)
    print(port)
    url = "http://127.0.0.1:{0}".format(port)
    print(url)
    app.run(port=port, host='0.0.0.0')

Hello. Why doesn't it work?

https://freeimage.host/i/X6SMv4

If you do get('10.0.0.10:5420').json() nothing happens.

You should deploy the web app using the UI on the Web page, you will not be able to run it on a localhost. See this help page.