The static directory was broken for some reason
This commit is contained in:
@ -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:
|
||||
|
@ -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.
|
||||
|
@ -14,21 +14,17 @@ TEST_FILE = "tests/test.mp4"
|
||||
|
||||
|
||||
def test_version():
|
||||
"""Test that version is correct."""
|
||||
"""Test version is correct."""
|
||||
assert __version__ == "1.0.0"
|
||||
|
||||
|
||||
def test_domain_ends_with_slash():
|
||||
"""Test that domain ends with slash."""
|
||||
"""Test domain ends with a slash."""
|
||||
assert not settings.serve_domain.endswith("/")
|
||||
|
||||
|
||||
def test_generate_html_for_videos():
|
||||
"""Test that generate_html_for_videos() works."""
|
||||
# TODO: We should probably import this from settings.py instead of
|
||||
# hardcoding it here. If we change it in settings.py, it won't be
|
||||
# changed here.
|
||||
|
||||
"""Test generate_html_for_videos() works."""
|
||||
domain = os.environ["SERVE_DOMAIN"]
|
||||
|
||||
# Remove trailing slash from domain
|
||||
@ -46,16 +42,12 @@ def test_generate_html_for_videos():
|
||||
|
||||
|
||||
def test_video_resolution():
|
||||
"""Test that video_resolution() works."""
|
||||
"""Test video_resolution() works."""
|
||||
assert video_resolution(TEST_FILE) == (422, 422)
|
||||
|
||||
|
||||
def test_make_thumbnail():
|
||||
"""Test that make_thumbnail() works."""
|
||||
# TODO: We should probably import this from settings.py instead of
|
||||
# hardcoding it here. If we change it in settings.py, it won't be
|
||||
# changed here.
|
||||
|
||||
"""Test make_thumbnail() works."""
|
||||
domain = os.environ["SERVE_DOMAIN"]
|
||||
|
||||
# Remove trailing slash from domain
|
||||
@ -63,30 +55,30 @@ def test_make_thumbnail():
|
||||
domain = domain[:-1]
|
||||
|
||||
thumbnail = make_thumbnail(TEST_FILE, "test.mp4")
|
||||
# Check that thumbnail is a jpeg.
|
||||
# Check if thumbnail is a jpeg.
|
||||
assert imghdr.what(f"{settings.upload_folder}/test.mp4.jpg") == "jpeg"
|
||||
|
||||
# Check that the it returns the correct URL.
|
||||
# Check if it returns the correct URL.
|
||||
assert thumbnail == f"{domain}/test.mp4.jpg"
|
||||
|
||||
|
||||
def test_save_to_disk():
|
||||
"""Test that save_to_disk() works."""
|
||||
"""Test save_to_disk() works."""
|
||||
# TODO: Implement this test. I need to mock the UploadFile object.
|
||||
|
||||
|
||||
def test_do_things():
|
||||
"""Test that do_things() works."""
|
||||
"""Test do_things() works."""
|
||||
# TODO: Implement this test. I need to mock the UploadFile object.
|
||||
|
||||
|
||||
def test_send_webhook():
|
||||
"""Test that send_webhook() works."""
|
||||
"""Test send_webhook() works."""
|
||||
send_webhook("Running Pytest")
|
||||
|
||||
|
||||
def test_main():
|
||||
"""Test that main() works."""
|
||||
"""Test main() works."""
|
||||
data_without_trailing_nl = ""
|
||||
response = client.get("/")
|
||||
|
||||
@ -104,10 +96,6 @@ def test_main():
|
||||
|
||||
def test_upload_file():
|
||||
"""Test if we can upload files."""
|
||||
# TODO: We should probably import this from settings.py instead of
|
||||
# hardcoding it here. If we change it in settings.py, it won't be
|
||||
# changed here.
|
||||
|
||||
domain = os.environ["SERVE_DOMAIN"]
|
||||
|
||||
# Remove trailing slash from domain
|
||||
|
Reference in New Issue
Block a user