본문 바로가기

response4

Python requests를 사용하여 이미지를 다운로드하는 방법은 다음과 같습니다., How to download image using requests 질문 나는 파이썬의 requests 모듈을 사용하여 웹에서 이미지를 다운로드하고 저장하려고 시도하고 있습니다. 다음은 사용한 (작동하는) 코드입니다: img = urllib2.urlopen(settings.STATICMAP_URL.format(**data)) with open(path, 'w') as f: f.write(img.read()) requests를 사용한 새로운 (작동하지 않는) 코드는 다음과 같습니다: r = requests.get(settings.STATICMAP_URL.format(**data)) if r.status_code == 200: img = r.raw.read() with open(path, 'w') as f: f.write(img) requests에서 응답으로부터 사용할 속성.. 2023. 10. 17.
Flutter request.send()를 사용하여 응답 본문을 어떻게 가져올 수 있나요?, How to get response body with request.send() in dart 질문 I'm doing an api request uploading an image with var request = new http.MultipartRequest("POST", uri); var response = await request.send() in dart using flutter. I can then check the response code with for instance if (response.statusCode == 200) { print('ok'); } with other calls I can also get the response body with var result = response.body; however when using request.send() I can't seem t.. 2023. 8. 16.
Flutter 처리되지 않은 예외: 'InternalLinkedHashMap<String, dynamic>'은(는) 'List<dynamic>' 유형의 하위 유형이 아닙니다., Unhandled Exception: InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic> 질문 나는 서버에서 JSON 응답을 가져와 콘솔에 출력하려고 노력하고 있습니다. Future login() async { var response = await http.get( Uri.encodeFull("https://etrans.herokuapp.com/test/2"), headers: {"Accept": "application/json"}); this.setState(() { data = json.decode(response.body); }); print(data[0].name); return "Success!"; } Unhandled Exception: type '_InternalLinkedHashMap' is not a subtype of type 'List 이유는 무엇일까요? 답변 다음은 잘못.. 2023. 6. 1.
Flutter에서 다른 StatefulWidget에서 StatefulWidget의 상태를 설정/업데이트하는 방법은 무엇인가요?, How to Set/Update State of StatefulWidget from other StatefulWidget in Flutter? 질문 예를 들어 아래 코드에서는 더하기 버튼이 작동하여 텍스트를 업데이트할 수 있지만, 마이너스 버튼은 그렇지 않습니다. 하지만 FloatingActionButton을 누르면 상태가 새로 고침됩니다. 마이너스 버튼은 변수의 값을 변경하지만 부모 위젯의 상태를 업데이트하지 않습니다. 여기 코드가 있습니다... import 'package:flutter/material.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter Demo', theme: new ThemeD.. 2023. 6. 1.