from fastapi import FastAPI, HTTPException from typing import List, Optional, Dict app = FastAPI() @app.get('/', response_model=List[Dict[str, str]]) def get_items(): try: with open('.version') as f: module_version = f.read().strip() if not module_version: raise ValueError("Version file is empty") except FileNotFoundError: raise HTTPException(status_code=404, detail="Version file not found") except Exception as e: raise HTTPException(status_code=500, detail=str(e)) data_info = [{"module_name": "Crypto Licensing", "module_version": module_version}] return data_info @app.get('/check_license/{license_key}', response_model=Dict[str, str]) def get_item(license_key: str): return {"license_key": license_key} # @app.post('/items', response_model=Item) # def create_item(item: Item): # data.append(item) # return item if __name__ == '__main__': import uvicorn # 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)