staticfiles served

This commit is contained in:
boyska 2020-12-15 14:57:06 +01:00
parent ac5f298c7d
commit 1965c19bc4
3 changed files with 17 additions and 6 deletions

10
requirements.txt Normal file
View file

@ -0,0 +1,10 @@
SQLAlchemy==0.8.3
aiofiles==0.6.0
click==7.1.2
fastapi==0.62.0
h11==0.11.0
pydantic==1.7.3
starlette==0.13.6
techrec @ file:///home/gordo/my/ror/techrec
typing-extensions==3.7.4.3
uvicorn==0.13.1

View file

@ -13,7 +13,7 @@ setup(
author_email="piuttosto@logorroici.org", author_email="piuttosto@logorroici.org",
packages=["techrec"], packages=["techrec"],
package_dir={"techrec": "techrec"}, package_dir={"techrec": "techrec"},
install_requires=["SQLAlchemy==0.8.3", "fastapi==0.62.0"], install_requires=["SQLAlchemy==0.8.3", "fastapi==0.62.0", "aiofiles==0.6.0"],
classifiers=["Programming Language :: Python :: 3.7"], classifiers=["Programming Language :: Python :: 3.7"],
entry_points={"console_scripts": ["techrec = techrec.cli:main"]}, entry_points={"console_scripts": ["techrec = techrec.cli:main"]},
zip_safe=False, zip_safe=False,

View file

@ -4,10 +4,10 @@ import logging
import os import os
import unicodedata import unicodedata
from datetime import datetime from datetime import datetime
from functools import partial
from fastapi import FastAPI, HTTPException, Response from fastapi import FastAPI, HTTPException, Response
from fastapi.responses import RedirectResponse from fastapi.responses import RedirectResponse
from fastapi.staticfiles import StaticFiles
from .cli import common_pre from .cli import common_pre
from .config_manager import get_config from .config_manager import get_config
@ -258,7 +258,7 @@ def get_archive():
@app.get("/api/help") @app.get("/api/help")
@app.get("/api") @app.get("/api")
def help(): def api_help():
return Response( return Response(
media_type="text/html", media_type="text/html",
content=""" content="""
@ -290,9 +290,10 @@ def rec_err(msg, **kwargs):
return self.rec_msg(msg, status=False, **kwargs) return self.rec_msg(msg, status=False, **kwargs)
# TODO: serve /output/<filepath:path> reading from get_config()['AUDIO_OUTPUT'] app.mount("/output", StaticFiles(directory=get_config()["AUDIO_OUTPUT"]))
# TODO: serve /static/<filepath:path> reading from get_config()['STATIC_FILES'] app.mount("/static", StaticFiles(directory=get_config()["STATIC_FILES"]))
# TODO: self._app.route("/", callback=lambda: redirect("/new.html"))
@app.get("/") @app.get("/")
def home(): def home():
return RedirectResponse("/new.html") return RedirectResponse("/new.html")