Начало создания API сервиса лицензирования

This commit is contained in:
stirelshka8_BigARM 2025-03-02 18:10:58 +03:00
parent 510c5f779c
commit e3e0f82207
2 changed files with 98 additions and 0 deletions

41
app.py Normal file
View File

@ -0,0 +1,41 @@
from fastapi import FastAPI
from pydantic import BaseModel
from typing import List, Optional
app = FastAPI()
# Модель данных
class Item(BaseModel):
id: int
name: str
# Пример данных
data = [
Item(id=1, name='Item 1'),
Item(id=2, name='Item 2')
]
@app.get('/items', response_model=List[Item])
def get_items():
return data
@app.get('/items/{item_id}', response_model=Optional[Item])
def get_item(item_id: int):
item = next((item for item in data if item.id == item_id), None)
return item
@app.post('/items', response_model=Item)
def create_item(item: Item):
data.append(item)
return item
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, host='127.0.0.1', port=8000)

57
requirements.txt Normal file
View File

@ -0,0 +1,57 @@
annotated-types==0.7.0
anyio==4.8.0
backports.tarfile==1.2.0
build==1.2.2.post1
CacheControl==0.14.0
certifi==2024.8.30
cffi==1.16.0
charset-normalizer==3.3.0
cleo==2.1.0
click==8.1.8
crashtest==0.4.1
cryptography==41.0.4
distlib==0.3.8
dulwich==0.22.7
fastapi==0.115.11
fastjsonschema==2.18.1
filelock==3.16.1
findpython==0.6.2
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
idna==3.4
importlib-metadata==6.8.0
installer==0.7.0
jaraco.classes==3.3.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jeepney==0.8.0
keyring==25.6.0
more-itertools==10.1.0
msgpack==1.0.7
packaging==24.1
pbs-installer==2025.2.12
pipenv==2024.4.1
pkginfo==1.12.0
platformdirs==4.3.6
poetry==2.1.1
poetry-core==2.1.1
pycparser==2.21
pydantic==2.10.6
pydantic_core==2.27.2
pyproject_hooks==1.0.0
rapidfuzz==3.5.2
requests==2.31.0
requests-toolbelt==1.0.0
SecretStorage==3.3.3
shellingham==1.5.3
sniffio==1.3.1
starlette==0.46.0
tomlkit==0.12.1
trove-classifiers==2023.9.19
typing_extensions==4.12.2
urllib3==2.0.6
uvicorn==0.34.0
virtualenv==20.29.2
zipp==3.17.0
zstandard==0.23.0