Skip to content

Commit

Permalink
Add fix for local setup (#6)
Browse files Browse the repository at this point in the history
* Fix poetry setup

* Add fix for local setup
  • Loading branch information
maastrich authored Oct 27, 2023
1 parent 5548305 commit d9c7ee3
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 313 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Install poetry using pip:
pip install poetry
```

Install dependencies:
Set virtual environment location to local folder:

```bash
poetry install
poetry config virtualenvs.in-project true
```

Load the virtual environment:
Install dependencies:

```bash
poetry shell
poetry install
```

Run the server:
Expand All @@ -26,6 +26,9 @@ Run the server:
poetry run python main.py
```

> **Note**
>
## Part 1

- Create a first endpoint to get horse results with as option the horseback category as optional filter. Use GET method.
Expand Down
21 changes: 8 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from flask import Flask, request, abort, jsonify, Response
import random
from flask import Flask, request, jsonify
import datetime
import concurrent.futures

import services
from models.horse import Horse

app = Flask(__name__) # Create a flask app

Expand All @@ -19,19 +17,17 @@ def base_route():
date = datetime.datetime.now()
print(date.strftime("%Y-%m-%d %H:%M:%S.%f"))

return Response(
return jsonify(
{
"routes_available": [
{
"route": "/horse/<horseId>?category=",
"verb": "GET",
"description": "Return the horse results for 2023",
"description": "Return the horse results for current year",
}
]
},
mimetype="application/json",
}
)
return


@app.route("/horse/<horseId>")
Expand All @@ -45,18 +41,17 @@ def get_horse_results(horseId):
category : optional category to filter on
Returns: the Horse object
"""
args = request.args

print(f"Category:{args.get('category', default=None, type=str)}")

# To be implemented

abort(404, description="Resource not found")
raise NotImplementedError()


# Set the correct methods for this route
@app.route("/horse/export-podium", methods=[""])
@app.route("/horse/export-podium", methods=["TODO"])
def export_podium():
"""Return the podium per categories for 3 best horses.
Expand All @@ -80,4 +75,4 @@ def bad_request(e):


if __name__ == "__main__":
app.run(host="0.0.0.0", port=random.randint(2000, 9000))
app.run(host="0.0.0.0", port=8800)
Loading

0 comments on commit d9c7ee3

Please sign in to comment.