Skip to content

Commit

Permalink
additional restapi
Browse files Browse the repository at this point in the history
  • Loading branch information
dickreuter committed Dec 7, 2023
1 parent 51ab8ad commit 2596265
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions poker/restapi_local.py
Expand Up @@ -5,21 +5,31 @@
from fastapi import FastAPI, Response
from fastapi.middleware.cors import CORSMiddleware

from poker.tools.helper import COMPUTER_NAME
from poker.tools.screen_operations import take_screenshot

app = FastAPI()

app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173",
"http://deepermind-pokerbot.com"], # Allow this origin
allow_origins=[
"http://localhost:5173",
"http://deepermind-pokerbot.com",
], # Allow this origin
allow_credentials=True,
allow_methods=["*"], # Allow all methods
allow_headers=["*"], # Allow all headers
)


def local_restapi():
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # You might want to be more specific in production.
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

@app.get("/take_screenshot")
async def get_screenshot_result():
Expand All @@ -29,3 +39,8 @@ async def get_screenshot_result():
return Response(content=image_bytes_io.getvalue(), media_type="image/png")

uvicorn.run(app, host="127.0.0.1", port=8005)


@app.get("/get_computer_name")
async def get_computer_name():
return {"computer_name": COMPUTER_NAME}

0 comments on commit 2596265

Please sign in to comment.