Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrelefevre committed Jan 3, 2024
1 parent f0e0deb commit 25577c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ COPY ./api /app

EXPOSE 8080

ENV PYTHONBUFFERED=1

CMD ["python", "server.py"]
12 changes: 10 additions & 2 deletions api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
import flask
from flask_cors import CORS

print("Bostadspriser API")


app = flask.Flask(__name__)
CORS(app)

print("Loading data")


def read_file():
with open("listings.json", "r") as f:
data = json.load(f)
return data


data = read_file()


@app.route("/", methods=["GET"])
def home():
return "Bostadspriser API"
Expand All @@ -29,8 +37,6 @@ def get_listings():
skip = int(args.get("skip", 0))
limit = int(args.get("limit", 10))

data = read_file()

return flask.jsonify(data[skip : skip + limit])


Expand All @@ -39,4 +45,6 @@ def predict():
return 42


print("Starting server")

app.run(host="0.0.0.0", port=8080)

0 comments on commit 25577c4

Please sign in to comment.