First attempt at using blueprints
Some checks failed
continuous-integration/drone the build failed

This commit is contained in:
Jef Roosens 2021-05-18 23:12:00 +02:00
parent a53921b429
commit ea8721659c
Signed by: Jef Roosens
GPG key ID: 955C0660072F691F
5 changed files with 27 additions and 4 deletions

View file

@ -1,7 +1,9 @@
"""Main entrypoint for the program."""
"""Entrypoint for the program."""
from quart import Quart
from app.api import blueprint
app = Quart("jos", static_folder="web/dist", static_url_path="/")
app.register_blueprint(blueprint)
@app.route("/", methods=["GET"], defaults={"path": ""})
@ -11,4 +13,6 @@ async def frontend(path):
return await app.send_static_file("index.html")
app.run(host="0.0.0.0")
if __name__ == "__main__":
print(app.url_map)
app.run(host="0.0.0.0")

8
app/api/__init__.py Normal file
View file

@ -0,0 +1,8 @@
"""Module containing all Flask-related code."""
from quart import Blueprint
from .search import blueprint as search_blueprint
# Main blueprint exposing entire API
blueprint = Blueprint("api", __name__, url_prefix="/api")
blueprint.register_blueprint(search_blueprint)

11
app/api/search.py Normal file
View file

@ -0,0 +1,11 @@
"""Handles the search endpoint."""
from quart import Blueprint
blueprint = Blueprint("search", __name__, url_prefix="/search")
@blueprint.route("/", methods=["GET"])
async def search_spotify():
"""Search the Spotify API."""
return "yeet"