I am currently trying to create an endpoint which can be called by other computers on the same network as me. Following is the sample code I am working with
from flask import Flask, request, jsonify
import requests
app = Flask(__name__)
countries = [
{"id": 1, "name": "Thailand", "capital": "Bangkok", "area": 513120},
{"id": 2, "name": "Australia", "capital": "Canberra", "area": 7617930},
{"id": 3, "name": "Egypt", "capital": "Cairo", "area": 1010408},
]
@app.get("/countries")
def get_countries():
return jsonify(countries)
Currently the above endpoint can be called at
http://127.0.0.1:5000/countries
from my own PC. How can I configure it such that it can be called from other computers on my network. I tried replacing 127.0.0.1
with my PC name but connection was refused.