abi445 commited on
Commit
b1d9da9
1 Parent(s): 6664141

Update pythonproject.py

Browse files
Files changed (1) hide show
  1. pythonproject.py +30 -30
pythonproject.py CHANGED
@@ -1,31 +1,31 @@
1
- from fastapi import FastAPI
2
- from fastapi.middleware.cors import CORSMiddleware
3
- import gradio as gr
4
-
5
- # Your existing Gradio interface code here
6
- def image_generator(prompt):
7
- # Your image generation logic here
8
- pass
9
-
10
- interface = gr.Interface(fn=image_generator, inputs="text", outputs="image")
11
-
12
- # Wrap the Gradio interface with FastAPI
13
- app = FastAPI()
14
-
15
- # Add CORS middleware
16
- app.add_middleware(
17
- CORSMiddleware,
18
- allow_origins=["https://abiel0.github.io", "https://abielai.uk.to"], # Add your domain(s) here
19
- allow_credentials=True,
20
- allow_methods=["*"],
21
- allow_headers=["*"],
22
- )
23
-
24
- # Mount the Gradio app
25
- app = gr.mount_gradio_app(app, interface, path="/")
26
-
27
- # If you're not using Gradio, you can just use FastAPI directly:
28
- # @app.post("/predict")
29
- # async def predict(data: dict):
30
- # # Your prediction logic here
31
  # pass
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ import gradio as gr
4
+
5
+ # Your existing Gradio interface code here
6
+ def image_generator(prompt):
7
+ # Your image generation logic here
8
+ pass
9
+
10
+ interface = gr.Interface(fn=image_generator, inputs="text", outputs="image")
11
+
12
+ # Wrap the Gradio interface with FastAPI
13
+ app = FastAPI()
14
+
15
+ # Add CORS middleware
16
+ app.add_middleware(
17
+ CORSMiddleware,
18
+ allow_origins=["*"], # Add your domain(s) here
19
+ allow_credentials=True,
20
+ allow_methods=["*"],
21
+ allow_headers=["*"],
22
+ )
23
+
24
+ # Mount the Gradio app
25
+ app = gr.mount_gradio_app(app, interface, path="/")
26
+
27
+ # If you're not using Gradio, you can just use FastAPI directly:
28
+ # @app.post("/predict")
29
+ # async def predict(data: dict):
30
+ # # Your prediction logic here
31
  # pass