mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-22 16:14:20 +01:00
fix: package
This commit is contained in:
0
__init__.py
Normal file
0
__init__.py
Normal file
2
setup.py
2
setup.py
@@ -7,7 +7,7 @@ def read_requirements():
|
||||
|
||||
setup(
|
||||
name='gptdeploy',
|
||||
version='0.17',
|
||||
version='0.1.7',
|
||||
description='Use natural language interface to create, deploy and update your microservice infrastructure.',
|
||||
long_description=open('README.md', 'r', encoding='utf-8').read(),
|
||||
long_description_content_type='text/markdown',
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = '0.17'
|
||||
__version__ = '0.1.7'
|
||||
106
src/server.py
106
src/server.py
@@ -1,53 +1,53 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional, Dict
|
||||
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import JSONResponse
|
||||
from main import main
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# Define the request model
|
||||
class CreateRequest(BaseModel):
|
||||
test_scenario: str
|
||||
executor_description: str
|
||||
|
||||
# Define the response model
|
||||
class CreateResponse(BaseModel):
|
||||
result: Dict[str, str]
|
||||
success: bool
|
||||
message: Optional[str]
|
||||
|
||||
@app.post("/create", response_model=CreateResponse)
|
||||
def create_endpoint(request: CreateRequest):
|
||||
|
||||
result = main(
|
||||
executor_description=request.executor_description,
|
||||
test_scenario=request.test_scenario,
|
||||
)
|
||||
return CreateResponse(result=result, success=True, message=None)
|
||||
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Add a custom exception handler for RequestValidationError
|
||||
@app.exception_handler(RequestValidationError)
|
||||
def validation_exception_handler(request: Request, exc: RequestValidationError):
|
||||
return JSONResponse(
|
||||
status_code=422,
|
||||
content={"detail": exc.errors()},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run("server:app", host="0.0.0.0", port=8000, log_level="info")
|
||||
# from fastapi import FastAPI
|
||||
# from fastapi.exceptions import RequestValidationError
|
||||
# from pydantic import BaseModel
|
||||
# from typing import Optional, Dict
|
||||
#
|
||||
# from starlette.middleware.cors import CORSMiddleware
|
||||
# from starlette.requests import Request
|
||||
# from starlette.responses import JSONResponse
|
||||
# from main import main
|
||||
#
|
||||
# app = FastAPI()
|
||||
#
|
||||
# # Define the request model
|
||||
# class CreateRequest(BaseModel):
|
||||
# test_scenario: str
|
||||
# executor_description: str
|
||||
#
|
||||
# # Define the response model
|
||||
# class CreateResponse(BaseModel):
|
||||
# result: Dict[str, str]
|
||||
# success: bool
|
||||
# message: Optional[str]
|
||||
#
|
||||
# @app.post("/create", response_model=CreateResponse)
|
||||
# def create_endpoint(request: CreateRequest):
|
||||
#
|
||||
# result = main(
|
||||
# executor_description=request.executor_description,
|
||||
# test_scenario=request.test_scenario,
|
||||
# )
|
||||
# return CreateResponse(result=result, success=True, message=None)
|
||||
#
|
||||
#
|
||||
# app.add_middleware(
|
||||
# CORSMiddleware,
|
||||
# allow_origins=["*"],
|
||||
# allow_credentials=True,
|
||||
# allow_methods=["*"],
|
||||
# allow_headers=["*"],
|
||||
# )
|
||||
#
|
||||
# # Add a custom exception handler for RequestValidationError
|
||||
# @app.exception_handler(RequestValidationError)
|
||||
# def validation_exception_handler(request: Request, exc: RequestValidationError):
|
||||
# return JSONResponse(
|
||||
# status_code=422,
|
||||
# content={"detail": exc.errors()},
|
||||
# )
|
||||
#
|
||||
#
|
||||
# if __name__ == "__main__":
|
||||
# import uvicorn
|
||||
# uvicorn.run("server:app", host="0.0.0.0", port=8000, log_level="info")
|
||||
|
||||
Reference in New Issue
Block a user