Spaces:
Sleeping
Sleeping
Durand D'souza
commited on
No need for ui redirect anymore
Browse files
main.py
CHANGED
|
@@ -21,25 +21,25 @@ app.add_middleware(
|
|
| 21 |
allow_headers=["*"],
|
| 22 |
)
|
| 23 |
|
| 24 |
-
app = gr.mount_gradio_app(app, interface, path="/ui")
|
| 25 |
|
| 26 |
-
@app.get("/")
|
| 27 |
-
async def read_main(request: Request):
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
-
|
| 42 |
|
| 43 |
@app.get("/solarpv/")
|
| 44 |
def get_lcoe(pv_assumptions: Annotated[SolarPVAssumptions, Query()]):
|
| 45 |
-
return calculate_lcoe(pv_assumptions)
|
|
|
|
|
|
| 21 |
allow_headers=["*"],
|
| 22 |
)
|
| 23 |
|
|
|
|
| 24 |
|
| 25 |
+
# @app.get("/")
|
| 26 |
+
# async def read_main(request: Request):
|
| 27 |
+
# # Get query parameters as dictionary
|
| 28 |
+
# query_params = dict(request.query_params)
|
| 29 |
|
| 30 |
+
# # Create new URL with parameters
|
| 31 |
+
# print(request.url.components)
|
| 32 |
+
# print(request.url.scheme)
|
| 33 |
+
# print(request.url.netloc)
|
| 34 |
+
# print("hf.space" in request.url.netloc)
|
| 35 |
+
# redirect_url = (request.url.scheme if "hf.space" not in request.url.netloc else "https") + "://" + request.url.netloc + request.url.path + "ui"
|
| 36 |
+
# print(redirect_url)
|
| 37 |
+
# if query_params:
|
| 38 |
+
# redirect_url += "?" + urlencode(query_params)
|
| 39 |
|
| 40 |
+
# return RedirectResponse(redirect_url)
|
| 41 |
|
| 42 |
@app.get("/solarpv/")
|
| 43 |
def get_lcoe(pv_assumptions: Annotated[SolarPVAssumptions, Query()]):
|
| 44 |
+
return calculate_lcoe(pv_assumptions)
|
| 45 |
+
app = gr.mount_gradio_app(app, interface, path="/")
|
ui.py
CHANGED
|
@@ -102,7 +102,7 @@ def get_share_url(
|
|
| 102 |
"project_lifetime_years": project_lifetime_years,
|
| 103 |
"dcsr": dcsr,
|
| 104 |
}
|
| 105 |
-
base_url = "
|
| 106 |
return gr.Button(link=base_url + urlencode(params))
|
| 107 |
|
| 108 |
with gr.Blocks(theme="citrus") as interface:
|
|
|
|
| 102 |
"project_lifetime_years": project_lifetime_years,
|
| 103 |
"dcsr": dcsr,
|
| 104 |
}
|
| 105 |
+
base_url = "?"
|
| 106 |
return gr.Button(link=base_url + urlencode(params))
|
| 107 |
|
| 108 |
with gr.Blocks(theme="citrus") as interface:
|