kamau1 commited on
Commit
5ecc89c
1 Parent(s): 6c2f3c3

Update modules/app.py

Browse files
Files changed (1) hide show
  1. modules/app.py +14 -1
modules/app.py CHANGED
@@ -6,7 +6,8 @@
6
  '''
7
 
8
  from fastapi import FastAPI, HTTPException, Request
9
- from fastapi.middleware.cors import CORSMiddleware
 
10
  from fastapi.responses import HTMLResponse
11
  import gradio as gr
12
  import ctranslate2
@@ -19,6 +20,18 @@ import os
19
 
20
  app = FastAPI()
21
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  fasttext.FastText.eprint = lambda x: None
23
 
24
  # Get time of request
 
6
  '''
7
 
8
  from fastapi import FastAPI, HTTPException, Request
9
+ from fastapi_middleware import Middleware
10
+ from fastapi_middleware.cors import CORSMiddleware
11
  from fastapi.responses import HTMLResponse
12
  import gradio as gr
13
  import ctranslate2
 
20
 
21
  app = FastAPI()
22
 
23
+ origins = ["*"]
24
+
25
+ app.add_middleware(
26
+ Middleware(
27
+ CORSMiddleware,
28
+ allow_origins=origins,
29
+ allow_credentials=False,
30
+ allow_methods=["*"],
31
+ allow_headers=["*"],
32
+ )
33
+ )
34
+
35
  fasttext.FastText.eprint = lambda x: None
36
 
37
  # Get time of request