mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2024-11-05 17:03:58 +03:00
Сделал аналитику, пофиксил роуты, сделал SSL
This commit is contained in:
parent
05fb43c53a
commit
a101eb7c1f
3 changed files with 39 additions and 9 deletions
10
Dockerfile
10
Dockerfile
|
@ -1,11 +1,13 @@
|
|||
FROM python:3.12
|
||||
|
||||
WORKDIR /starlio-web
|
||||
WORKDIR /
|
||||
|
||||
COPY ./requirements.txt /starlio-web/requirements.txt
|
||||
COPY ./requirements.txt ./
|
||||
|
||||
RUN pip3 install --no-cache-dir --upgrade -r /starlio-web/requirements.txt
|
||||
RUN pip3 install --no-cache-dir --upgrade -r ./requirements.txt
|
||||
|
||||
COPY ./ /starlio-web/
|
||||
COPY . .
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["python", "main.py"]
|
13
docker-compose.yaml
Normal file
13
docker-compose.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
services:
|
||||
starlio-web:
|
||||
build: .
|
||||
ports:
|
||||
- '8000:8000'
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- './CertSSL:/CertSSL'
|
||||
- './config.yaml:/config.yaml'
|
||||
|
||||
volumes:
|
||||
starlio-web:
|
||||
driver: local
|
25
main.py
25
main.py
|
@ -1,14 +1,20 @@
|
|||
import uvicorn
|
||||
import yaml
|
||||
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from starlette.responses import FileResponse
|
||||
from fastapi import FastAPI
|
||||
import uvicorn
|
||||
import os
|
||||
from src.middleware.plausible_analytics import PlausibleAnalytics
|
||||
|
||||
config = yaml.safe_load(open('./config.yaml'))
|
||||
|
||||
from src.routes import index
|
||||
from src.routes import wallpaper
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.middleware('http')(PlausibleAnalytics())
|
||||
|
||||
app.include_router(index.router)
|
||||
app.include_router(wallpaper.router)
|
||||
|
||||
|
@ -17,12 +23,12 @@ app.mount('/.well-known/', StaticFiles(directory='./.well-known/'))
|
|||
|
||||
|
||||
@app.get('/app-ads.txt')
|
||||
async def app_ads(req):
|
||||
async def app_ads():
|
||||
return FileResponse('./app-ads.txt')
|
||||
|
||||
|
||||
@app.get('/robots.txt')
|
||||
async def robots_txt(req):
|
||||
async def robots_txt():
|
||||
return FileResponse('./robots.txt')
|
||||
|
||||
|
||||
|
@ -31,4 +37,13 @@ async def not_found(req, __):
|
|||
return FileResponse('./src/web/html/error/404.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
uvicorn.run(app, host="0.0.0.0", port=int(os.environ['PORT']))
|
||||
uvicorn.run(app,
|
||||
host=config['server']['host'],
|
||||
port=8000,
|
||||
ssl_keyfile=config['server']['ssl_privkey']
|
||||
if config['server']['ssl_work']
|
||||
else None,
|
||||
ssl_certfile=config['server']['ssl_cert']
|
||||
if config['server']['ssl_work']
|
||||
else None
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue