Spaces:
Running
Running
File size: 1,094 Bytes
b697ed4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
from fastapi import FastAPI
import json, utility
app = FastAPI()
# ADDING ORIGINS
from fastapi.middleware.cors import CORSMiddleware
origins = [
"http://127.0.0.1:5500", # local host
"https://geetu040.github.io", # where app is hosted
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def index():
return {"Hello": "World"}
@app.get("/intelli-snake/map-{info}")
def intelliSnake2_map(info:str):
returned_info = utility.load_map( json.loads(info) )
return json.dumps(returned_info)
@app.get("/intelli-snake/automate-{info}")
def automate(info:str):
predicted_dirs = utility.automate( json.loads(info) )
return predicted_dirs
@app.get("/intelli-snake/automate_faster-{info}")
def automate_faster(info:str):
returned_infos = utility.automate_faster( json.loads(info) )
return json.dumps(returned_infos)
@app.get("/intelli-snake/write-{content}")
def write(content:str):
with open("latest_dataset.txt", "a") as f:
f.write(content)
return "nothing" |