Skip to content

Commit

Permalink
Update api docs (#87)
Browse files Browse the repository at this point in the history
* Update API docs - change protocol from http to https
  • Loading branch information
ajwalkiewicz authored Dec 20, 2023
1 parent 613f8e9 commit 0ac7369
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
22 changes: 11 additions & 11 deletions webapp/templates/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h2>
<div class="col">
<span class="badge bg-success">200</span> Success
<p>
<kbd>curl -X GET http://www.cochar.pl/api/v1/get</kbd>
<kbd>curl -X GET https://www.cochar.pl/api/v1/get</kbd>
</p>
<pre>
{
Expand Down Expand Up @@ -91,7 +91,7 @@ <h4><kbd>year</kbd></h4>
<span class="badge bg-danger">400</span> Bad Request
<p>
<kbd
>curl -X GET http://www.cochar.pl/api/v1/get?year=invalid</kbd
>curl -X GET https://www.cochar.pl/api/v1/get?year=invalid</kbd
>
</p>
<pre>
Expand All @@ -116,7 +116,7 @@ <h4><kbd>country</kbd></h4>
<p>
<kbd
>curl -X GET
http://www.cochar.pl/api/v1/get?country=invalid</kbd
https://www.cochar.pl/api/v1/get?country=invalid</kbd
>
</p>
<pre>
Expand Down Expand Up @@ -157,7 +157,7 @@ <h4><kbd>age</kbd></h4>
</p>
<span class="badge bg-danger">400</span> Bad Request
<p>
<kbd>curl -X GET http://www.cochar.pl/api/v1/get?age=14</kbd>
<kbd>curl -X GET https://www.cochar.pl/api/v1/get?age=14</kbd>
</p>
<pre>
{
Expand All @@ -168,7 +168,7 @@ <h4><kbd>age</kbd></h4>

<span class="badge bg-danger">400</span> Bad Request
<p>
<kbd>curl -X GET http://www.cochar.pl/api/v1/get?age=invalid</kbd>
<kbd>curl -X GET https://www.cochar.pl/api/v1/get?age=invalid</kbd>
</p>
<pre>
{
Expand All @@ -186,7 +186,7 @@ <h4><kbd>sex</kbd></h4>
<p>Choices to specify gender: "M", "F"</p>
<span class="badge bg-danger">400</span> Bad Request
<p>
<kbd>curl -X GET http://www.cochar.pl/api/v1/get?sex=invalid</kbd>
<kbd>curl -X GET https://www.cochar.pl/api/v1/get?sex=invalid</kbd>
</p>
<pre>
{
Expand Down Expand Up @@ -224,7 +224,7 @@ <h4><kbd>era</kbd></h4>
<p>"classic-1890" is not supported</p>
<span class="badge bg-danger">400</span> Bad Request
<p>
<kbd>curl -X GET http://www.cochar.pl/api/v1/get?era=invalid</kbd>
<kbd>curl -X GET https://www.cochar.pl/api/v1/get?era=invalid</kbd>
</p>
<pre>
{
Expand All @@ -251,7 +251,7 @@ <h4><kbd>occup_type</kbd></h4>
<p>
<kbd
>curl -X GET
http://www.cochar.pl/api/v1/get?occup_type=invalid</kbd
https://www.cochar.pl/api/v1/get?occup_type=invalid</kbd
>
</p>
<pre>
Expand All @@ -273,7 +273,7 @@ <h4><kbd>tags</kbd></h4>
<span class="badge bg-danger">400</span> Bad Request
<p>
<kbd
>curl -X GET http://www.cochar.pl/api/v1/get?tags=invalid</kbd
>curl -X GET https://www.cochar.pl/api/v1/get?tags=invalid</kbd
>
</p>
<pre>
Expand All @@ -294,7 +294,7 @@ <h4><kbd>occupation</kbd></h4>
</p>
<span class="badge bg-danger">400</span> Bad Request
<p>
<kbd>curl -X GET http://www.cochar.pl/api/v1/get?occupation=invalid</kbd>
<kbd>curl -X GET https://www.cochar.pl/api/v1/get?occupation=invalid</kbd>
</p>
<pre>
{
Expand All @@ -317,7 +317,7 @@ <h5>None of the occupation meet searching criteria:</h5>
<span class="badge bg-danger">400</span> Bad Request
<p>
<kbd
>curl -X GET http://www.cochar.pl/api/v1/get?era=modern&tags=lovecraftian</kbd
>curl -X GET https://www.cochar.pl/api/v1/get?era=modern&tags=lovecraftian</kbd
>
</p>
<pre>
Expand Down
5 changes: 3 additions & 2 deletions webapp/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
OCCUPATIONS = cochar.occup.get_occupation_list()
LIMITS = ["10 per second", "10000 per day"]


def get_remote_address() -> str:
"""Get client's IP address.
pythonanywhere.com stores original client's IP in 'X-Real-IP' header.
Expand All @@ -39,7 +40,7 @@ def get_remote_address() -> str:
:return: client's IP address
:rtype: str
"""
return request.headers.get('X-Real-IP') or request.remote_addr or "127.0.0.1"
return request.headers.get("X-Real-IP") or request.remote_addr or "127.0.0.1"


with open(_README, "r", encoding="utf-8") as readme:
Expand Down Expand Up @@ -174,7 +175,7 @@ def get(self):
"\nPlease try again later.\n"
"If you did not exceed the limit check if someone "
"else in your network is using this website"
)
),
}, 429


Expand Down

0 comments on commit 0ac7369

Please sign in to comment.