Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -1,10 +1,20 @@
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
|
|
|
| 2 |
from pydantic import BaseModel, Field
|
| 3 |
from typing import Optional
|
| 4 |
from cold.classifier import ToxicTextClassifier
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
model = ToxicTextClassifier()
|
| 9 |
|
| 10 |
class PredictionInput(BaseModel):
|
|
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from pydantic import BaseModel, Field
|
| 4 |
from typing import Optional
|
| 5 |
from cold.classifier import ToxicTextClassifier
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
| 9 |
+
app.add_middleware(
|
| 10 |
+
CORSMiddleware,
|
| 11 |
+
allow_origins=["*"],
|
| 12 |
+
allow_credentials=True,
|
| 13 |
+
allow_methods=["*"],
|
| 14 |
+
allow_headers=["*"],
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
model = ToxicTextClassifier()
|
| 19 |
|
| 20 |
class PredictionInput(BaseModel):
|