网络编程 -- flask Posted on 2024-06-18 | In Net , flask | demo.py 123456789101112from flask import Flask, request, jsonify, Responsapp = Flask(__name__)@app.route('/hi', methods=['GET', 'POST'])def hello_world(): logger.info('---hi Qiansi Tech SR') return 'Qiansi Tech SR'if __name__ == '__main__': # Rel Server [gunnicor run in 9020] app.run(port=9021) # test in 9021 client 1234567891011121314def request_demo(test_on_server=False): try: # url = 'http://127.0.0.1:{}/cycle/hi'.format(args.port) # url = 'http://cartoon.fuyuncc.com/cycle/hi'.format(args.port) url = 'http://cartoon.fuyuncc.com/srserver/hi' if test_on_server: url = 'http://127.0.0.1:9021/hi' print('-url', url) r = requests.get(url) print(r) print(r.text) except Exception as e: print(e)