Dockerfile
This commit is contained in:
parent
c59894d62c
commit
d0d959b7ef
8 changed files with 75 additions and 19 deletions
|
@ -5,9 +5,12 @@ import requests
|
|||
from datetime import datetime
|
||||
|
||||
from fastapi import FastAPI
|
||||
from app.routes import router
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.routes import router
|
||||
from utils import declension
|
||||
from app.models import Project
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
|
@ -19,6 +22,9 @@ app.add_middleware(
|
|||
)
|
||||
app.include_router(router)
|
||||
|
||||
repos = []
|
||||
code_stats = {}
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
def start():
|
||||
|
@ -55,9 +61,12 @@ def load_code_stats():
|
|||
|
||||
code_stats[el['name']] = ''
|
||||
if hours > 0:
|
||||
code_stats[el['name']] = get_declension(hours, 'час', 'часа', 'часов') + ' '
|
||||
code_stats[el['name']] = declension(hours, 'час', 'часа', 'часов') + ' '
|
||||
if minutes > 0:
|
||||
code_stats[el['name']] += get_declension(minutes, 'минуту', 'минуты', 'минут') + ' '
|
||||
code_stats[el['name']] += declension(minutes, 'минуту', 'минуты', 'минут') + ' '
|
||||
if code_stats[el['name']] == '':
|
||||
code_stats.pop(el['name'])
|
||||
time.sleep(7200)
|
||||
time.sleep(7200)
|
||||
|
||||
|
||||
__all__ = ['code_stats', 'repos', 'app']
|
13
backend/app/config.py
Normal file
13
backend/app/config.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from datetime import datetime
|
||||
from pydantic import BaseSettings
|
||||
|
||||
|
||||
class Config(BaseSettings):
|
||||
host: str = '127.0.0.1'
|
||||
port: int = 8888
|
||||
birthdate: datetime
|
||||
|
||||
|
||||
config = Config(_env_file='.env')
|
||||
|
||||
__all__ = ['config']
|
1
backend/app/models/__init__.py
Normal file
1
backend/app/models/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from project import Project
|
8
backend/app/models/project.py
Normal file
8
backend/app/models/project.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Project:
|
||||
name: str
|
||||
description: str
|
||||
link: str
|
|
@ -1 +1,27 @@
|
|||
from datetime import datetime
|
||||
from fastapi import APIRouter
|
||||
from app.utils import declension
|
||||
|
||||
from app import code_stats, repos
|
||||
from app.config import config
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/api/get_repos")
|
||||
def get_repos():
|
||||
return repos
|
||||
|
||||
|
||||
@router.get("/api/get_code_stats")
|
||||
def get_code_stats():
|
||||
return code_stats
|
||||
|
||||
|
||||
@router.get("/api/get_age")
|
||||
def get_age():
|
||||
today = datetime.today()
|
||||
age = today.year - config.birthdate.year - (
|
||||
(today.month, today.day) < (config.birthdate.month, config.birthdate.day))
|
||||
return declension(age, 'год', 'года', 'лет')
|
||||
|
||||
|
|
16
backend/poetry.lock
generated
16
backend/poetry.lock
generated
|
@ -1,4 +1,4 @@
|
|||
# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "anyio"
|
||||
|
@ -21,18 +21,6 @@ doc = ["packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"]
|
|||
test = ["contextlib2", "coverage[toml] (>=4.5)", "hypothesis (>=4.0)", "mock (>=4)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (<0.15)", "uvloop (>=0.15)"]
|
||||
trio = ["trio (>=0.16,<0.22)"]
|
||||
|
||||
[[package]]
|
||||
name = "argparse"
|
||||
version = "1.4.0"
|
||||
description = "Python command-line parsing library"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "argparse-1.4.0-py2.py3-none-any.whl", hash = "sha256:c31647edb69fd3d465a847ea3157d37bed1f95f19760b11a47aa91c04b666314"},
|
||||
{file = "argparse-1.4.0.tar.gz", hash = "sha256:62b089a55be1d8949cd2bc7e0df0bddb9e028faefc8c32038cc84862aefdd6e4"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "certifi"
|
||||
version = "2022.12.7"
|
||||
|
@ -359,4 +347,4 @@ standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)",
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "7ac5dfa898af0c96eeb29f6592b9fe62c558ae5f367150a876f62da54a531d36"
|
||||
content-hash = "701467840b1645daf1e62f8aaf1321f73043db620457d49330ae14461a8c7ebe"
|
||||
|
|
|
@ -9,7 +9,6 @@ readme = "README.md"
|
|||
python = "^3.10"
|
||||
uvicorn = "^0.22.0"
|
||||
fastapi = "^0.95.1"
|
||||
argparse = "^1.4.0"
|
||||
requests = "^2.29.0"
|
||||
|
||||
|
||||
|
|
12
frontend/Dockerfile
Normal file
12
frontend/Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
|||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN yarn install --production=true
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
COPY . .
|
||||
CMD ["yarn", "dev", "--port", "3000"]
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue