upgrade to bootstrap5

This commit is contained in:
boyska 2024-12-07 19:38:37 +01:00
parent dfb7e4f167
commit d197f80d7b
7 changed files with 74 additions and 32 deletions

View file

@ -13,6 +13,7 @@ from sqlalchemy.orm import sessionmaker
from fastapi import FastAPI, UploadFile, Header, Form, HTTPException from fastapi import FastAPI, UploadFile, Header, Form, HTTPException
from fastapi.requests import Request from fastapi.requests import Request
from fastapi.responses import RedirectResponse from fastapi.responses import RedirectResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates from fastapi.templating import Jinja2Templates
from pydantic import BaseModel from pydantic import BaseModel
@ -29,6 +30,10 @@ engine = create_engine(CONFIG["general"]["db"])
database.metadata.create_all(engine) database.metadata.create_all(engine)
session_pool = sessionmaker(bind=engine) session_pool = sessionmaker(bind=engine)
app.mount("/static",
StaticFiles(directory=str(Path(__file__).parent / "static")),
name="static")
@app.get("/") @app.get("/")
def home(): def home():

File diff suppressed because one or more lines are too long

6
caricari/static/lib/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,30 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/static/lib/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<title>{%block title%}{%endblock%}</title>
</head>
<body>
{% block navbar %}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="{{url_for('home')}}">Media upload</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="{{url_for('upload')}}">Upload</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{url_for('list')}}">List</a>
</li>
</ul>
</div>
</div>
</nav>
{% endblock navbar %}
{% block body %}
{% endblock %}
<script src="/static/lib/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>

View file

@ -1,13 +1,14 @@
<html> {% extends "base.html" %}
<head> {% block title%}Upload file{%endblock%}
<title>Upload file</title>
</head> {%block body%}
<body>
<h1>Upload file</h1> <h1>Upload file</h1>
<form method="POST" enctype="multipart/form-data"> <form method="POST" enctype="multipart/form-data">
<input type="file" name="file" /> <div class="mb-3">
<input type=submit /> <label for="formFile" class="form-label">Seleziona file da caricare</label>
<input id="formFile" class="form-control form-control-lg" type="file" name="file" />
</div>
<button type=submit class="btn btn-primary">Invia</button>
</form> </form>
</body> {%endblock %}
</html>

View file

@ -1,24 +1,21 @@
<html> {% extends "base.html" %}
<head> {% block title%}Upload list{%endblock%}
<style>
.filelist td.name { {% block body %}
font-family: monospace; <table class="table table-hover filelist" >
}
</style>
</head>
<body>
<table class="filelist" width="100%">
<thead> <thead>
<th>Name</th> <tr>
<th>Size</th> <th scope="col">Name</th>
<th></th> <th scope="col">Size</th>
<th scope="col"></th>
</tr>
</thead> </thead>
<tbody> <tbody>
{% for orig in files %} {% for orig in files %}
<tr> <tr>
<td class="name"> <td class="name">
<span>{{orig.name}}</span> <span>{{orig.name}}</span>
<button class="copy" data-text="{{orig.url}}">📋</button> <button class="btn btn-outline-secondary copy" data-text="{{orig.url}}">📋</button>
</td> </td>
<td class="size">{{orig.size}}</td> <td class="size">{{orig.size}}</td>
</tr> </tr>
@ -53,5 +50,4 @@ if (navigator && navigator.clipboard && navigator.clipboard.writeText) { // supp
document.querySelectorAll(".filelist tbody td.name button.copy").forEach(function(el) { el.remove() }) document.querySelectorAll(".filelist tbody td.name button.copy").forEach(function(el) { el.remove() })
} }
</script> </script>
</body> {% endblock body %}
</html>

View file

@ -1,13 +1,10 @@
<html> {% extends "base.html" %}
<head> {% block title%}File has been uploaded{%endblock%}
<title>File has been uploaded</title> {%block body%}
</head>
<body>
<h1>Success!</h1> <h1>Success!</h1>
<p> <p>
File has been loaded at <tt>{{url}}</tt> File has been loaded at <tt>{{url}}</tt>
</p> </p>
</body> {%endblock%}
</html>