diff --git a/.gitignore b/.gitignore index c6dc124..e98d96b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /keys/ *.pem /output.txt +/.env diff --git a/app.py b/app.py index a1cc4eb..58aa58e 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,4 @@ from fastapi import FastAPI, HTTPException -from pydantic import BaseModel from typing import List, Optional, Dict app = FastAPI() @@ -36,4 +35,5 @@ def get_item(license_key: str): if __name__ == '__main__': import uvicorn - uvicorn.run(app, host='127.0.0.1', port=8000) + # uvicorn.run("app:app", host='127.0.0.1', port=8000, workers=4) + uvicorn.run("app:app", host='127.0.0.1', port=8000, reload=True) diff --git a/db.py b/db.py index 269f5f8..736af09 100644 --- a/db.py +++ b/db.py @@ -1,22 +1,19 @@ +import os import psycopg2 -from psycopg2 import sql +from dotenv import load_dotenv -# Настройки подключения -host = "localhost" -port = "5432" -user = "postgres" -password = "postgres" -database_name = "postgres" -table_name = "licenses" +load_dotenv() + +table_name = 'licenses' def connect_to_database(): connection = psycopg2.connect( - host=host, - port=port, - user=user, - password=password, - database=database_name + host=os.getenv('db_host'), + port=os.getenv('db_port'), + user=os.getenv('db_user'), + password=os.getenv('db_password'), + database=os.getenv('db_name') ) return connection, connection.cursor() @@ -33,7 +30,7 @@ class LicenseDatabase: owner_license VARCHAR(255) NOT NULL, expiration_date DATE NOT NULL, device_count INT NOT NULL, - license_key VARCHAR(500) -- Добавлена запятая здесь + license_key VARCHAR(500) ); """ self.cursor.execute(create_table_query) diff --git a/requirements.ini b/requirements.ini new file mode 100644 index 0000000..bfbf32c --- /dev/null +++ b/requirements.ini @@ -0,0 +1,58 @@ +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 +psycopg2-binary==2.9.10 +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 diff --git a/requirements.txt b/requirements.txt index 54b6b3b..ed51f89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -55,3 +55,6 @@ uvicorn==0.34.0 virtualenv==20.29.2 zipp==3.17.0 zstandard==0.23.0 + +psycopg2-binary~=2.9.10 +python-dotenv~=1.0.1 \ No newline at end of file