How to create a Post request with streamlit

Hi @chukypedro,

you mention several points here.

1. File_uploader
Streamlit offers a component for file uploading including video files (I belief):

import streamlit as st
import cv2 as cv
import tempfile

--> f = st.file_uploader("Upload file") <--
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.write(f.read())
vf = cv.VideoCapture(tfile.name)

2. Requests in python
You can than send a request to the API using:

import requests
url = 'https://www.w3schools.com/python/demopage.php'
myobj = {'somekey': 'somevalue'}
x = requests.post(url, data = myobj)
print(x.text)

3. API
Finally, you can implement an API with:

and smoothly process and return the data.

In case you are using streamlit sharing, you might not need to send the data somewhere to store files.
I have a similar question posted a few minutes ago:

Hope that helps you :slightly_smiling_face:have a nice day.
Cheers
Chris

2 Likes