Разработан веб-сервер и игровое поле

This commit is contained in:
2024-07-26 02:13:03 +03:00
commit 55abdb2867
14 changed files with 860 additions and 0 deletions

1
models/__init__.py Normal file
View File

@ -0,0 +1 @@
from .main import area_width, area_height, pixel_size, headers, User, Pixel, Area, RequestsFrequency

53
models/main.py Normal file
View File

@ -0,0 +1,53 @@
from pydantic import BaseModel, Field, IPvAnyNetwork
from datetime import datetime as DateTime, date as Date
area_width = 64
area_height = 32
pixel_size = 24
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Headers': '*',
}
class User(BaseModel):
id: int
ip_address: IPvAnyNetwork
created: Date
progress: int
colors: list[int]
class Pixel(BaseModel):
x: int = Field(
...,
ge=0,
le=area_width - 1,
)
y: int = Field(
...,
ge=0,
le=area_height - 1,
)
color: int = Field(
...,
ge=0x000000,
le=0xFFFFFF,
)
last_update: DateTime
class Area(BaseModel):
width: int = area_width
height: int = area_height
pixel_size: int = pixel_size
pixels: list[Pixel]
class RequestsFrequency(BaseModel):
per_second: int
per_minute: int
per_hour: int
per_day: int