from fastapi import FastAPI
from app.sql import test
from pydantic import BaseModel
from starlette.requests import Request
from starlette.responses import Response
from starlette.testclient import TestClient


from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()

origins = ["https://3dshell.hu/"]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials = True,
    allow_methods=["*"],
    allow_headers=["*"]
)


class receivedData(BaseModel):
    msg: str

@app.get('/')
async def root():
    return {'message:' : 'Hello worldx2'}

# @app.post("/test")
# async def testReceive(req: receivedData):

#     print("The req is: "+req)
#     # response = receivedData+" Received!"
#     return {"message: " : "hello"}



@app.post("/test")
async def testReceive(req: Request):

    print(req.body())
    # response = receivedData+" Received!"
    return '{message: " : "hello"}'


# @app.post("/v1/check-ip/")
# async def check_for_conflicts(veri_data: request_body) -> dict:
#     """Meh"""
#     subs = veri_data.ip1, veri_data.ip2
#     res = check_conflicts(subs, quiet=True)
#     return res
