We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3993589 commit 4babd7aCopy full SHA for 4babd7a
main.py
@@ -1,10 +1,31 @@
1
-from typing import Union
2
-
3
from fastapi import FastAPI
+from fastapi.middleware.cors import CORSMiddleware
+import logging
4
+
5
+app = FastAPI(title="api")
6
7
+logging.basicConfig(
8
+ level=logging.INFO,
9
+ format="%(asctime)s [%(name)s] %(levelname)s: %(message)s",
10
+)
11
+logger = logging.getLogger(__name__)
12
13
+origins = [
14
+ "http://localhost/ping",
15
+ "http://localhost",
16
+ "http://localhost:8080",
17
+]
18
-app = FastAPI()
19
+app.add_middleware(
20
+ CORSMiddleware,
21
+ allow_origins=origins,
22
+ allow_credentials=True,
23
+ allow_methods=["*"],
24
+ allow_headers=["*"],
25
26
27
28
@app.get("/ping")
29
def read_root():
30
+ logging.info("GET '/ping'")
31
return "pong"
0 commit comments