title: Sending a Post request to Flask API, but not receiving data
body: <p>So I am trying to send certain values to my Flask API streamlit application, but it appears that it is not executing a post request. Right now, the post request code I have for my <code>main.py</code> does not work because I am getting a <code>TypeError: 'NoneType'</code>.</p>
  <p><strong>app.py</strong> :</p>
  <pre><code>import requests
  import json
  import streamlit as st
  ...
  api_url = &quot;http://127.0.0.1:5000/&quot; # Flask url
  create_row_data = {'name': name, 'type': get_type(name), 'token_value': token_value, 
  'external': external, 'start': start, 'end': end, 'step': step}
  print(create_row_data)
  
  # The terminal cannot print out the value of r and it appears that it cannot send the post request as well
  r = requests.post(url=api_url, json = create_row_data)
  print(r)
  </code></pre>
  <p>Output of <code>print(create_row_data)</code> in app.py:</p>
  <pre><code>{'name': 'session', 'type': 'area_chart', 'token_value': 'G0as7vjk1ksuxn94', 
  'external': False, 'start': datetime.datetime(2021,7,1,14,9,7,322438), 'end': datetime.datetime(2021,7,8,14,9,7,322441), 'step': '1d'}
  </code></pre>
  <p><strong>main.py</strong>:</p>
  <pre><code>from flask import Flask
  from flask import jsonify
  from flask import request
  ...
  import requests, json
  @app.route('/', methods=['GET', 'POST'])
  def get_data():
     if request.method == 'GET':
         return &quot;ok&quot;, 200
     if request.method =='POST':
        p_name = request.json['name']
        p_type = request.json['type']
        ...
        p_end = request.json['end']
        p_step = request.json['step']
        create_row_data = {'p_name': str(p_name), 'p_type': str(p_type), ... , 'p_end': str(p_end), 'p_step': str(p_step)}
        print(create_row_data)  
        response = requests.post(url, data=json.dumps(create_row_data), headers= {'Content-type': 'application/json'}
        return response.content
  </code></pre>