Your Name 4 jaren geleden
bovenliggende
commit
e40be32951
1 gewijzigde bestanden met toevoegingen van 18 en 1 verwijderingen
  1. 18 1
      similar_server/main.py

+ 18 - 1
similar_server/main.py

@@ -6,11 +6,28 @@ import os
 import dataset
 import datetime
 import json
-
+from fastapi.middleware.cors import CORSMiddleware
 db = dataset.connect('sqlite:///similar.db')
 
+
 app = FastAPI()
 
+origins = [
+    "http://www.googo.org",
+    "http://googo.org",
+    "http://139.162.121.30"
+]
+
+app.add_middleware(
+    CORSMiddleware,
+    allow_origins=origins,
+    allow_credentials=True,
+    allow_methods=["*"],
+    allow_headers=["*"],
+)
+
+
+
 @app.get("/domain/{domain_name}")
 async def read_item(domain_name):
     cursor=db.query('select domain_name,json,dt from similar where domain_name="'+domain_name+'"')