rename directories

This commit is contained in:
2025-07-14 17:02:31 +08:00
parent 742c8f5931
commit 0c8d6cbd06
21 changed files with 523 additions and 0 deletions

1
python-fastapi/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/

6
python-fastapi/README.md Normal file
View File

@ -0,0 +1,6 @@
# Get started
```sh
uv venv
uv run fastapi dev main.py
```

31
python-fastapi/main.py Normal file
View File

@ -0,0 +1,31 @@
from typing import Union
from fastapi import FastAPI
from pydantic import BaseModel
class Transfer(BaseModel):
amount: int
sender: str
receiver: str
app = FastAPI()
accounts = {
'1': {'amount': 1000},
'2': {'amount': 1000},
}
transactions: list[Transfer] = []
@app.post("/transfer")
def transfer(transfer: Transfer):
amount = transfer.amount
sender = transfer.sender
receiver = transfer.receive
if amount <= 0:
return {"error": "Amount must be greater than 0"}
print(f"transfer {amount} from {sender} to {receiver}")
return {"amount": amount, "sender": sender, "receiver": receiver}