Spaces:
Sleeping
Sleeping
Update api.py
Browse files
api.py
CHANGED
@@ -7,6 +7,21 @@ from fastapi import FastAPI, Request
|
|
7 |
from fastapi.responses import StreamingResponse
|
8 |
import sentencepiece as spm
|
9 |
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
sp = spm.SentencePieceProcessor()
|
12 |
sp.load("kolig_unigram.model")
|
|
|
7 |
from fastapi.responses import StreamingResponse
|
8 |
import sentencepiece as spm
|
9 |
app = FastAPI()
|
10 |
+
|
11 |
+
from fastapi.middleware.cors import CORSMiddleware
|
12 |
+
|
13 |
+
origins = [
|
14 |
+
"https://insect5386.github.io",
|
15 |
+
"https://insect5386.github.io/insect5386"
|
16 |
+
]
|
17 |
+
|
18 |
+
app.add_middleware(
|
19 |
+
CORSMiddleware,
|
20 |
+
allow_origins=origins,
|
21 |
+
allow_credentials=True,
|
22 |
+
allow_methods=["*"],
|
23 |
+
allow_headers=["*"],
|
24 |
+
)
|
25 |
|
26 |
sp = spm.SentencePieceProcessor()
|
27 |
sp.load("kolig_unigram.model")
|