So I am trying to send certain values to my Flask API from my streamlit application, but I am not sure as to why I am getting a type error(Using this as reference: Sending a POST request to my RESTful API(Python-Flask), but receiving a GET request).
Type error: The view function for 'get_data' did not return a valid response. The function either returned None or ended without a return statement
app.py
import requests
import streamlit as st
...
api_url = requests.get("http://127.0.0.1:5000/") # 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)
r = requests.post(url=api_url, json = create_row_data)
The url
in the main.py has https
main.py
@app.route('/', methods=['GET', 'POST'])
def get_data():
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
What I want to do is send the values to my Flask API which would then use those values, return a dataframe, and send the dataframe to the streamlit application.
Any help is greatly appreciated.