alaa-ahmed14 commited on
Commit
cf07078
·
verified ·
1 Parent(s): bc5f9c0

Create space.py

Browse files
Files changed (1) hide show
  1. space.py +25 -0
space.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ import uvicorn
4
+
5
+ app = FastAPI()
6
+
7
+ # Add CORS middleware to allow requests from any origin
8
+ app.add_middleware(
9
+ CORSMiddleware,
10
+ allow_origins=["*"],
11
+ allow_credentials=True,
12
+ allow_methods=["*"],
13
+ allow_headers=["*"],
14
+ )
15
+
16
+ @app.get("/")
17
+ async def read_root():
18
+ return {"Hello": "World"}
19
+
20
+ # Function to run the app in Hugging Face Spaces
21
+ def run():
22
+ uvicorn.run(app, host="0.0.0.0", port=7860)
23
+
24
+ if __name__ == "__main__":
25
+ run()