The static directory was broken for some reason

This commit is contained in:
2022-08-02 16:38:12 +02:00
parent 1fc17b319c
commit 8e30543625
3 changed files with 17 additions and 29 deletions

View File

@ -1,7 +1,7 @@
"""Generate the HTML that makes this program useful.
This is what we will send to other people on Discord.
You can remove the .html with your web server so the link will look normal.
You can remove the .html with your web server, so the link will look normal.
For example, with nginx, you can do this(note the $uri.html):
location / {
try_files $uri $uri/ $uri.html;
@ -27,7 +27,7 @@ def generate_html_for_videos(
url: URL for the video. This is accessible from the browser.
width: This is the width of the video.
height: This is the height of the video.
screenshot: URL for screenshot.
screenshot: URL for the screenshot.
filename: Original video filename.
Returns:

View File

@ -27,7 +27,7 @@ app = FastAPI(
},
)
app.mount("/static", StaticFiles(directory="static"), name="static")
app.mount("/static", StaticFiles(directory="../static"), name="static")
templates = Jinja2Templates(directory="templates")
@ -35,7 +35,7 @@ templates = Jinja2Templates(directory="templates")
async def upload_file(file: UploadFile = File(...)) -> Dict[str, str]:
"""Page for uploading files.
If it is a video, we need to make a HTML file, and a thumbnail
If it is a video, we need to make an HTML file, and a thumbnail
otherwise we can just save the file and return the URL for it.
If something goes wrong, we will send a message to Discord.
@ -43,13 +43,13 @@ async def upload_file(file: UploadFile = File(...)) -> Dict[str, str]:
file: Our uploaded file.
Returns:
Returns a dict with the filename or a link to the .html if it was a video.
Returns a dict with the filename, or a link to the .html if it was a video.
"""
domain_url = ""
if file.content_type.startswith("video/"):
return await do_things(file)
# Replace spaces with dots in filename.
# Replace spaces with dots in the filename.
filename = file.filename.replace(" ", ".")
# Remove ? from filename.