mirror of
				https://github.com/open-webui/openapi-servers
				synced 2025-06-26 18:17:04 +00:00 
			
		
		
		
	refac
This commit is contained in:
		
							parent
							
								
									b8a46d5af2
								
							
						
					
					
						commit
						7c72ccfe34
					
				| @ -1,5 +1,8 @@ | ||||
| from fastapi import FastAPI, HTTPException, Body | ||||
| from fastapi.responses import PlainTextResponse | ||||
| from fastapi.middleware.cors import CORSMiddleware | ||||
| 
 | ||||
| 
 | ||||
| from pydantic import BaseModel, Field | ||||
| import os | ||||
| import pathlib | ||||
| @ -9,10 +12,21 @@ import difflib | ||||
| 
 | ||||
| app = FastAPI( | ||||
|     title="Secure Filesystem API", | ||||
|     version="0.2.0", | ||||
|     version="0.1.0", | ||||
|     description="A secure file manipulation server for reading, editing, writing, listing, and searching files with access restrictions.", | ||||
| ) | ||||
| 
 | ||||
| origins = ["*"] | ||||
| 
 | ||||
| app.add_middleware( | ||||
|     CORSMiddleware, | ||||
|     allow_origins=origins, | ||||
|     allow_credentials=True, | ||||
|     allow_methods=["*"], | ||||
|     allow_headers=["*"], | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| # Constants | ||||
| ALLOWED_DIRECTORIES = [ | ||||
|     str(pathlib.Path(os.path.expanduser("~/mydir")).resolve()) | ||||
|  | ||||
| @ -1,4 +1,7 @@ | ||||
| from fastapi import FastAPI, HTTPException, Body | ||||
| from fastapi.middleware.cors import CORSMiddleware | ||||
| 
 | ||||
| 
 | ||||
| from pydantic import BaseModel, Field | ||||
| from datetime import datetime, timezone | ||||
| from typing import Literal | ||||
| @ -11,6 +14,18 @@ app = FastAPI( | ||||
|     description="Provides secure UTC/local time retrieval, formatting, timezone conversion, and comparison.", | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| origins = ["*"] | ||||
| 
 | ||||
| app.add_middleware( | ||||
|     CORSMiddleware, | ||||
|     allow_origins=origins, | ||||
|     allow_credentials=True, | ||||
|     allow_methods=["*"], | ||||
|     allow_headers=["*"], | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| # ------------------------------- | ||||
| # Pydantic models | ||||
| # ------------------------------- | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user