Spaces:
Paused
Paused
Clément Simon
commited on
Commit
•
a57706e
1
Parent(s):
d29a82e
fix: CORS policy for script.js
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
6 |
import plotly.graph_objects as go
|
7 |
from dotenv import load_dotenv
|
8 |
from fastapi import Depends, FastAPI, Request
|
|
|
9 |
from fastapi.responses import HTMLResponse, Response
|
10 |
from fastapi.staticfiles import StaticFiles
|
11 |
from fastapi.templating import Jinja2Templates
|
@@ -35,6 +36,14 @@ examples = ["Comment fait on pour produire du maïs ?",
|
|
35 |
# create a FastAPI app
|
36 |
app = FastAPI()
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
# create a static directory to store the static files
|
39 |
static_dir = Path('./static')
|
40 |
static_dir.mkdir(parents=True, exist_ok=True)
|
|
|
6 |
import plotly.graph_objects as go
|
7 |
from dotenv import load_dotenv
|
8 |
from fastapi import Depends, FastAPI, Request
|
9 |
+
from fastapi.middleware.cors import CORSMiddleware
|
10 |
from fastapi.responses import HTMLResponse, Response
|
11 |
from fastapi.staticfiles import StaticFiles
|
12 |
from fastapi.templating import Jinja2Templates
|
|
|
36 |
# create a FastAPI app
|
37 |
app = FastAPI()
|
38 |
|
39 |
+
# Add CORS middleware
|
40 |
+
app.add_middleware(
|
41 |
+
CORSMiddleware,
|
42 |
+
allow_origins=["*"], # Allows all origins
|
43 |
+
allow_credentials=True,
|
44 |
+
allow_methods=["*"], # Allows all methods
|
45 |
+
allow_headers=["*"], # Allows all headers
|
46 |
+
)
|
47 |
# create a static directory to store the static files
|
48 |
static_dir = Path('./static')
|
49 |
static_dir.mkdir(parents=True, exist_ok=True)
|