| Çöó½ºÅ© - ²À´ë±â Çöó½ºÅ©ÀÇ REST API ¿ë °£´ÜÇÑ ¾ç½Ä À¯È¿¼º °Ë»ç±â |
Áö±Ý ´Ù¿î·Îµå |
Çöó½ºÅ© - ²À´ë±â ¼øÀ§ ¹× ¿ä¾à
- °Ô½ÃÀÚ À̸§:
- Maycon Bordin
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- https://github.com/mayconbordin/
Çöó½ºÅ© - ²À´ë±â ű×
Çöó½ºÅ© - ²À´ë±â ¼³¸í
Flask-ApiformÀº Flask¿¡¼ REST API¸¦À§ÇÑ °£´ÜÇÑ ¾ç½Ä À¯È¿¼º °Ë»ç±âÀÔ´Ï´Ù. ¼³Ä¡ÇÏ·Á¸é : PIP ¼³Ä¡ Flask-Apiform Çʵå Çʵå Çʼö (Boolean, Default = True), Çã¿ë (¸ñ·Ï ¶Ç´Â Æ©ÇÃ), ±âº»°ª, ¼Ò½º (args , ÆÄÀÏ ¶Ç´Â URL) filefiewfield ±âº» (±âº»°ª = 10) hexfield ±æÀÌ, ÇÊÅÍ (±â´É) flask flask flaskext.apiform flasm from flaskext.apiform °¡Á® ¿À±â ¾ç½Ä , StringField, intfieldtry : JSON °¡Á® ¿À±â dumpsexcept infermerror : SimpleJSON °¡Á® ¿À±â ´ýÇÁ json (reswith = ', code = 200, headers = none) : ¹Ýȯ ÀÀ´ä (´ýÇÁ (ÀÀ´ä), ÄÚµå, mimetype ='ÀÀ¿ë ÇÁ·Î±×·¥ / json ', Çì´õ = Çì´õ) Ŭ·¡½º À妽º Æû (Æû) : name = StringField (minlength = 1, maxLength = 20) age = intfield (min = 1, max = 120) app = flask (__ name __) @ app.route ( "/") DEF »öÀÎ () : form = indexForm (¿äû) form.validate () : return json ({ '¸Þ½ÃÁö': 'À¯È¿¼º °Ë»ç ½ÇÆÐ', '¿À·ù': form.errors}, 422) return js on ({ 'name': form.name, 'age': form.age}) __name__ == "__main__": app.debug = true app.run () Á¦Ç° ȨÆäÀÌÁö
Çöó½ºÅ© - ²À´ë±â °ü·Ã ¼ÒÇÁÆ®¿þ¾î