-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Description
Hi,
I build a very simple web api by flask2.2.3 using python3.7.
I can use Postman and browser to connect this webapi but not working in c# Net6 by HttpClient.PostAsync.
Please help me to pass this error.
Thank you.
error message in c#:
{System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)}
here is the code:
from flask import Flask, jsonify, redirect, url_for, render_template,request, Response
import json
from flask_cors import CORS
app = Flask(name)
CORS(app)
@app.route('/qryData/', methods=['POST', 'GET'])
def qryData():
return jsonify(True);
if name == 'main':
app.run(host='0.0.0.0',port=58080,debug=True)
Thanks for your help.