How to use flask request properly to retrieve data from JSON?

تعرفه تبلیغات در سایت
عنوان عکس
عنوان عکس
عنوان عکس
عنوان عکس
عنوان عکس


یافته ها در جستجو

    امکانات وب

    آرشیو مطالب

    برچسب ها

    Vote count: 0

    I looked many questions similar to my title but I have not found any that had same problem as me yet.

    I did to post JSON to API restful server. Below is the snippet

    import requests
    def upload_data():
        url = ""
        data = {"value":"abc123"}
        response =, data=data)
        print response.status_code, response.reason, response.text

    And for the server side

    from flask_restful import Api, Resource
    from flask import request
    class MyAPI(Resource):
        def get():
        def post(self):
            value =['value']
            response_object = {
            return response_object, 201

    I was hoping to get the POST function to work by showing the result of 201 Created with


    But whenever I run the script, it gives me error saying that

        value =["value"]
    TypeError: string indices must be integers, not str

    I am sorry if this is a bad question but if anyone could show me what I have been missing in this script, I really appreciate it. Thank you.

    asked 44 secs ago

    نویسنده : استخدام کار بازدید : 59 تاريخ : پنجشنبه 28 ارديبهشت 1396 ساعت: 19:17
    برچسب‌ها :
    اخبار و رسانه هاهنر و ادبیاترایانه و اینترنتعلم و فن آوریتجارت و اقتصاداندیشه و مذهبفوتو بلاگوبلاگ و وبلاگ نویسیفرهنگ و تاریخجامعه و سیاستورزشسرگرمی و طنزشخصیخانواده و زندگیسفر و توریسمفارسی زبان در دیگر کشورهاads-123