Update app.py
Browse files
app.py
CHANGED
@@ -151,11 +151,25 @@ def get_response(user_input):
|
|
151 |
|
152 |
|
153 |
###############
|
154 |
-
|
|
|
|
|
|
|
155 |
from fastapi import FastAPI
|
|
|
156 |
|
157 |
app = FastAPI()
|
158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
@app.post("/generate/")
|
160 |
def generate(user_input):
|
161 |
print("----yuhu -----")
|
@@ -255,7 +269,7 @@ def get_all_links_from_domain(domain_url):
|
|
255 |
def simple(text:str):
|
256 |
return text +" hhhmmm "
|
257 |
|
258 |
-
|
259 |
fn=get_response,
|
260 |
#fn=simple,
|
261 |
# inputs=["text"],
|
@@ -268,10 +282,13 @@ app = gr.ChatInterface(
|
|
268 |
clear_btn=None
|
269 |
)
|
270 |
|
271 |
-
|
|
|
|
|
272 |
|
273 |
-
|
274 |
-
|
|
|
275 |
domain_url = 'https://globl.contact/'
|
276 |
links = get_all_links_from_domain(domain_url)
|
277 |
print("Links from the domain:", links)
|
|
|
151 |
|
152 |
|
153 |
###############
|
154 |
+
#####
|
155 |
+
#####
|
156 |
+
#####
|
157 |
+
####
|
158 |
from fastapi import FastAPI
|
159 |
+
from fastapi.middleware.cors import CORSMiddleware
|
160 |
|
161 |
app = FastAPI()
|
162 |
|
163 |
+
# middlewares to allow cross orgin communications
|
164 |
+
app.add_middleware(
|
165 |
+
CORSMiddleware,
|
166 |
+
allow_origins=['*'],
|
167 |
+
allow_credentials=True,
|
168 |
+
allow_methods=['*'],
|
169 |
+
allow_headers=['*'],
|
170 |
+
)
|
171 |
+
|
172 |
+
|
173 |
@app.post("/generate/")
|
174 |
def generate(user_input):
|
175 |
print("----yuhu -----")
|
|
|
269 |
def simple(text:str):
|
270 |
return text +" hhhmmm "
|
271 |
|
272 |
+
fe_app = gr.ChatInterface(
|
273 |
fn=get_response,
|
274 |
#fn=simple,
|
275 |
# inputs=["text"],
|
|
|
282 |
clear_btn=None
|
283 |
)
|
284 |
|
285 |
+
fe_app.launch(debug=True, share=True)
|
286 |
+
|
287 |
+
|
288 |
|
289 |
+
# load the model asynchronously on startup and save it into memory
|
290 |
+
@app.on_event("startup")
|
291 |
+
async def startup():
|
292 |
domain_url = 'https://globl.contact/'
|
293 |
links = get_all_links_from_domain(domain_url)
|
294 |
print("Links from the domain:", links)
|