我想创建一个gRPC服务,但是我需要在Winform .net应用程序中托管。 关于Hosting ASP.NET Core API in a Windows Forms Application 我希望有人向我解释,在该示例中,我需要安装什么以及应该更改什么,以便以Windows的形式托管grpc服务...
答案 0 :(得分:0)
您可以按照相同的步骤进行操作,但还要执行以下几个附加步骤:
def get_weather(lat,lon):
import json
import requests
r = requests.post('https://api.openweathermap.org/data/2.5/onecall?lat={}&lon={}&exclude=hourly,daily&appid=92d93ccc6ac5587d35d3ccc4479083a1'.format(lat,lon))
data = r.json()
dt = data["dt"]
temp = data["temp"]
weather = data["weather"]
humidity = data["humidity"]
wind_speed = data["wind_speed"]
print(r["dt"])
print(r["temp"])
print(r["weather"])
print(r["humidity"])
print(r["wind_speed"])
get_weather(33,44)
app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<MygRPCService>();
});
rpc Get(GetRequest) returns (GetReply) {
option (google.api.http) = {
get: '/my-endpoint'
body: '*'
};
}