Skip to content

Commit

Permalink
Merge pull request #7 from klepp-me/feature/static_video_page
Browse files Browse the repository at this point in the history
Add static video page to render share urls
  • Loading branch information
JonasKs authored Apr 17, 2022
2 parents 595b7af + 7219815 commit 7dc795a
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from app.api.security import cognito_scheme
from app.core.config import settings
from app.core.logging_config import setup_logging
from app.render.urls import api_router as render_router

app = FastAPI(
title=settings.PROJECT_NAME,
Expand All @@ -30,3 +31,4 @@

app.include_router(api_router, prefix=settings.API_V1_STR)
app.include_router(api_v2_router, prefix=settings.API_V2_STR)
app.include_router(render_router)
Empty file added app/render/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions app/render/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from fastapi import APIRouter

from app.render import video_player

api_router = APIRouter()
api_router.include_router(video_player.router, tags=['video'])
12 changes: 12 additions & 0 deletions app/render/video_player.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates

templates = Jinja2Templates(directory='templates')

router = APIRouter()


@router.get('/', response_class=HTMLResponse, include_in_schema=False)
async def render_video_page(request: Request, path: str):
return templates.TemplateResponse('video.html', {'request': request, 'path': path})
22 changes: 20 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
license = "MIT"

[tool.poetry.dependencies]
python = "3.10.2"
python = "^3.10.2"
fastapi = ">=0.72.0"
cryptography = ">=35.0.0"
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
Expand All @@ -30,6 +30,7 @@ aiofiles = "^0.8.0"
asyncffmpeg = "^1.2.0"
asynccpu = "^1.2.2"
ffmpeg-python = "^0.2.0"
Jinja2 = "^3.1.1"

[tool.poetry.dev-dependencies]
pre-commit = "^2.9.3"
Expand Down
28 changes: 28 additions & 0 deletions templates/video.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta property="og:title" content="Klepp"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="https://gg.klepp.me/{{path}}"/>
<meta property="og:video" content="https://gg.klepp.me/{{path}}"/>
<meta property="og:video:type" content="application/x-shockwave-flash">
<meta property="og:video:width" content="398">
<meta property="og:video:height" content="264">
<meta property="og:image" content="https://klepp.me/favicon.ico"/>
<meta name="theme-color" content="#FF0000">
<title>Klepp video</title>
<style>
body {background: linear-gradient(90deg,#0f2027,#36474f 50%,#2c5364)}
.videoplayer {width: 100%; height: 100%}
</style>
</head>
<body>
<div class="videoplayer">
<video controls>
<source src="https://gg.klepp.me/{{path}}" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</body>
</html>

0 comments on commit 7dc795a

Please sign in to comment.