Starting work on frontend.
This commit is contained in:
parent
679433525c
commit
7e915423a3
4 changed files with 60 additions and 5 deletions
|
|
@ -9,7 +9,8 @@ from crudkit.core.service import CRUDService
|
|||
from crudkit.integrations.flask import init_app
|
||||
|
||||
from .config import DevConfig
|
||||
from .db import init_db, create_all_tables, get_session
|
||||
|
||||
from .routes.index import init_index_routes
|
||||
|
||||
def create_app(config_cls=DevConfig) -> Flask:
|
||||
app = Flask(__name__)
|
||||
|
|
@ -49,14 +50,12 @@ def create_app(config_cls=DevConfig) -> Flask:
|
|||
app.register_blueprint(generate_crud_blueprint(_models.WorkLog, work_log_service), url_prefix="/api/work_log")
|
||||
app.register_blueprint(generate_crud_blueprint(_models.WorkNote, work_note_service), url_prefix="/api/work_note")
|
||||
|
||||
init_index_routes(app)
|
||||
|
||||
@app.teardown_appcontext
|
||||
def _remove_session(_exc):
|
||||
sess = app.extensions["crudkit"].get("Session")
|
||||
if sess is not None:
|
||||
sess.remove()
|
||||
|
||||
@app.get("/")
|
||||
def index():
|
||||
return {"status": "ok", "db": str(runtime.engine.url)}
|
||||
|
||||
return app
|
||||
0
inventory/routes/__init__.py
Normal file
0
inventory/routes/__init__.py
Normal file
10
inventory/routes/index.py
Normal file
10
inventory/routes/index.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from flask import Blueprint, request, jsonify, render_template
|
||||
|
||||
bp_index = Blueprint("index", __name__)
|
||||
|
||||
def init_index_routes(app):
|
||||
@bp_index.get("/")
|
||||
def index():
|
||||
return render_template("base.html")
|
||||
|
||||
app.register_blueprint(bp_index)
|
||||
46
inventory/templates/base.html
Normal file
46
inventory/templates/base.html
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}{{ title if title else "Inventory Manager" }}{% endblock %}</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
||||
<style>
|
||||
{% block style %}
|
||||
{% endblock %}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<nav>
|
||||
{{ title if title else "Inventory Manager" }}
|
||||
{% block header %}
|
||||
{% endblock %}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
{% block main %}
|
||||
<h1>{{ title if title else "Inventory Manager" }}</h1>
|
||||
{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
{% block footer %}
|
||||
{% endblock %}
|
||||
<p></p>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
{% block script %}
|
||||
{% endblock %}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue