본문 바로가기

파이썬9

Flask의 make_response에서 TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a list. from flask_marshmallow import Marshmallow ma = Marshmallow() class UserSchema(SQLAlchemyAutoSchema): class Meta: model = User users = [User(), User(), User(), ...] data = UserSchema().dump(users, many=True) res = make_response(data) File "C:\Users\...\flask\app.py", line 2127, in make_response raise TypeError( TypeError: The view function did not return a valid response. The return type must be .. 2021. 11. 3.
Google Drive에서 파일을 받으려는데 The requested conversion is not supported가 난다면 HttpError 400 어쩌구 'The requested conversion is not supported.' 구글 스프레이드 파일을 받으려하니 자체 포멧(슬라이드, 스프레드시트 등)은 그대로 내보내지 못해서 발생한 오류가 발생했다. 요청한 mimeType으로 내려줄 수 없다는 의미로 https://developers.google.com/drive/api/v3/ref-export-formats Google Workspace documents and corresponding export MIME types Google Workspace formats and supported export MIME types map to each other as follows: Google Doc Format Convers.. 2021. 1. 30.
Flask-SQLAlchemy의 Column에 subquery 사용 class Question(db.Model): ... answer_count = db.column_property(db.select([db.func.count(db.text('qid'))]) .select_from(db.text('answer')) .where(db.text('qid == question.id')) .correlate_except(db.text('answer')) .label('answer_count')) 2020. 12. 21.
Python으로 http 서버 띄우기 python -m http.server 로 띄울 수 있다. 물론 상용으로 쓰면 안되고 개발, 테스트 용도. http.server 모듈을 열어보면 if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('--cgi', action='store_true', help='Run as CGI Server') parser.add_argument('--bind', '-b', default='', metavar='ADDRESS', help='Specify alternate bind address ' '[default: all interfaces]') parser.add_argument('--direc.. 2020. 12. 16.