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.requests import Request
from fastapi.responses import RedirectResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from pydantic import BaseModel
@ -29,6 +30,10 @@ engine = create_engine(CONFIG["general"]["db"])
database.metadata.create_all(engine)
session_pool = sessionmaker(bind=engine)
app.mount("/static",
StaticFiles(directory=str(Path(__file__).parent / "static")),
name="static")
@app.get("/")
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>
<head>
<title>Upload file</title>
</head>
<body>
{% extends "base.html" %}
{% block title%}Upload file{%endblock%}
{%block body%}
<h1>Upload file</h1>
<form method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
<input type=submit />
<div class="mb-3">
<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>
</body>
</html>
{%endblock %}

View file

@ -1,24 +1,21 @@
<html>
<head>
<style>
.filelist td.name {
font-family: monospace;
}
</style>
</head>
<body>
<table class="filelist" width="100%">
{% extends "base.html" %}
{% block title%}Upload list{%endblock%}
{% block body %}
<table class="table table-hover filelist" >
<thead>
<th>Name</th>
<th>Size</th>
<th></th>
<tr>
<th scope="col">Name</th>
<th scope="col">Size</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for orig in files %}
<tr>
<td class="name">
<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 class="size">{{orig.size}}</td>
</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() })
}
</script>
</body>
</html>
{% endblock body %}

View file

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