From eeb4660a4e88dfdb9ecebe82d6467923b9b42803 Mon Sep 17 00:00:00 2001
From: Naserien <1959483977@qq.com>
Date: Tue, 23 Apr 2024 20:43:36 -0400
Subject: [PATCH] update env acquire
---
C_Sharp/WEB/Pages/Index.razor | 17 +++++++++++++----
C_Sharp/WEB/Startup.cs | 11 +++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
create mode 100644 C_Sharp/WEB/Startup.cs
diff --git a/C_Sharp/WEB/Pages/Index.razor b/C_Sharp/WEB/Pages/Index.razor
index ed13d51..efb68d9 100644
--- a/C_Sharp/WEB/Pages/Index.razor
+++ b/C_Sharp/WEB/Pages/Index.razor
@@ -1,4 +1,6 @@
@page "/"
+@inject IConfiguration Configuration
+@inject HttpClient httpClient
Photo Upload
@@ -27,7 +29,13 @@
private List uploadedFiles = new List();
private string uploadStatus = "";
private string statusClass = "";
- @inject HttpClient httpClient;
+ private string apiUrl;
+
+ protected override void OnInitialized()
+ {
+ apiUrl = Configuration["photo_process_url"];
+ base.OnInitialized();
+ }
private void OnInputFileChange(InputFileChangeEventArgs e)
{
@@ -48,9 +56,8 @@
try
{
- var functionUrl = Environment.GetEnvironmentVariable("photo_process_url");
- var response = await httpClient.PostAsync(functionUrl, content);
-
+ var response = await httpClient.PostAsync(apiUrl, content);
+
if (response.IsSuccessStatusCode)
{
// Handle the success scenario
@@ -76,6 +83,8 @@
await stream.DisposeAsync();
}
}
+
+ uploadedFiles.Clear(); // Clear the list after all files are processed
}
}
diff --git a/C_Sharp/WEB/Startup.cs b/C_Sharp/WEB/Startup.cs
new file mode 100644
index 0000000..d28bb7b
--- /dev/null
+++ b/C_Sharp/WEB/Startup.cs
@@ -0,0 +1,11 @@
+public class Startup
+{
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ // ...other codess...
+}