Yxxi4 commited on
Commit
d4dc133
·
verified ·
1 Parent(s): a5492dc

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -0
main.py CHANGED
@@ -190,8 +190,19 @@ def diacritize_text(text, model, char_to_idx, max_len=200):
190
  # ==========================================
191
  # 5. إعداد الخادم ومسارات الـ API
192
  # ==========================================
 
 
193
  app = FastAPI()
194
 
 
 
 
 
 
 
 
 
 
195
  class TextRequest(BaseModel):
196
  text: str
197
 
 
190
  # ==========================================
191
  # 5. إعداد الخادم ومسارات الـ API
192
  # ==========================================
193
+ from fastapi.middleware.cors import CORSMiddleware
194
+
195
  app = FastAPI()
196
 
197
+ # إضافة صلاحيات CORS للسماح لموقعك بالاتصال بالـ API
198
+ app.add_middleware(
199
+ CORSMiddleware,
200
+ allow_origins=["*"], # يسمح لجميع النطاقات (مثل Vercel) بالاتصال
201
+ allow_credentials=True,
202
+ allow_methods=["*"],
203
+ allow_headers=["*"],
204
+ )
205
+
206
  class TextRequest(BaseModel):
207
  text: str
208