Skip to content

Commit

Permalink
Fix routes (#171)
Browse files Browse the repository at this point in the history
* fix: move index redirect into blueprint

* feat: add favicon.ico
  • Loading branch information
dlbrittain authored Oct 31, 2024
1 parent 4c49665 commit df224d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions materializationengine/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np
from dynamicannotationdb.models import Base, AnalysisVersion
from flask import Blueprint, Flask, current_app, jsonify, redirect
from flask import Blueprint, Flask, current_app, jsonify, redirect, url_for
from flask_cors import CORS
from flask_restx import Api
from flask_sqlalchemy import SQLAlchemy
Expand All @@ -22,6 +22,7 @@
from materializationengine.views import views_bp
from materializationengine.limiter import limiter
from materializationengine.migrate import migrator

db = SQLAlchemy(model_class=Base)


Expand Down Expand Up @@ -68,6 +69,10 @@ def versions():
def version():
return jsonify(__version__), 200

@apibp.route("/")
def index():
return redirect("/materialize/views/")

db.init_app(app)
ma.init_app(app)

Expand All @@ -76,7 +81,10 @@ def version():

with app.app_context():
api = Api(
apibp, title="Materialization Engine API", version=__version__, doc="/doc"
apibp,
title="Materialization Engine API",
version=__version__,
doc="/api/doc",
)
api.add_namespace(mat_bp, path="/api/v2")
api.add_namespace(client_bp, path="/api/v2")
Expand All @@ -98,10 +106,6 @@ def health():
session.close()
return jsonify({aligned_volume: n_versions}), 200

@app.route("/materialize/")
def index():
return redirect("/materialize/views")

@app.teardown_appcontext
def shutdown_session(exception=None):
for key in sqlalchemy_cache._sessions:
Expand Down
Binary file added static/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% block title %}{% endblock %} - Materialization Service - v.{{version}}
</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" />
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<nav>
<ul>
<li>
Expand Down

0 comments on commit df224d6

Please sign in to comment.