crypto_api/app.py

35 lines
819 B
Python

from fastapi import FastAPI
from pydantic import BaseModel
from typing import List, Optional
app = FastAPI()
class Item(BaseModel):
module_name: str
module_version: str
@app.get('/', response_model=List[Item])
def get_items():
with open('.version') as f:
module_version = f.read().strip()
data_info = [Item(module_name="Crypto Licensing", module_version=module_version)]
return data_info
# @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)