Skip to content

Commit

Permalink
feat: Add Flask-RESTful for API functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
lamtonylam committed Aug 5, 2024
1 parent af2b5de commit cc7012e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
14 changes: 12 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask
from flask import render_template
from flask_restful import Resource, Api

from datetime import datetime

Expand All @@ -13,12 +14,12 @@
# response from api_url
response = requests.get(api_url)

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

# get todays date in format 07.05
date = datetime.now().strftime("%d.%m")

app = Flask(__name__)


def furtherst_date_data():
dates = []
Expand Down Expand Up @@ -140,3 +141,12 @@ def index():
global_sausage_search=unicafe_global_sausagesearch(),
furtherst_date_data=furtherst_date_data(),
)


# api
class UnicafeGlobalSausageSearch(Resource):
def get(self):
return unicafe_global_sausagesearch()


api.add_resource(UnicafeGlobalSausageSearch, "/api")
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
aniso8601==9.0.1
blinker==1.8.2
certifi==2024.7.4
charset-normalizer==3.3.2
click==8.1.7
flask==3.0.3
Flask-RESTful==0.3.10
gunicorn==22.0.0
idna==3.7
importlib-metadata==7.1.0
itsdangerous==2.2.0
jinja2==3.1.4
MarkupSafe==2.1.5
packaging==24.0
<<<<<<< HEAD
requests==2.32.2
urllib3==2.2.2
=======
pytz==2024.1
requests==2.31.0
six==1.16.0
urllib3==2.2.1
>>>>>>> 34f1a8c (feat: Add Flask-RESTful for API functionality)
werkzeug==3.0.3
zipp==3.19.1
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ <h3>
<hr />
<b>{{ location }}:</b> {% for date in dates %} {{ date }} {% endfor
%}
<hr />
</h3>
{% endfor %} {% endif %}
<hr />
<p>Tänään on: {{ date }}.</p>
<p>Data haettu {{furtherst_date_data}} asti</p>

Expand Down

0 comments on commit cc7012e

Please sign in to comment.