question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support custom HTTP requests

See original GitHub issue

See: https://discuss.streamlit.io/t/streamlit-restful-app/409

Some users would like to have their Streamlit servers work double duty as both a Streamlit app server and a data server (for REST endpoints, for example)

API proposal 1

A traditional-looking API for that would be something like:

st.server.add_route('foo', foo_callback)

Then, when a POST or GET HTTP request is made against /foo, the callback foo_callback would handle it and return a response.

I haven’t thought through whether this would be possible to implement given our current “run from the top” architecture. It’s possible this would require a big refactor.

API proposal 2

A more Streamlit-style API would be something like:

if st.server.request.foo == 'bar':
  st.server.respond({'data': df})
  # And .respond() would cause the script to finish executing immediately.

In this proposal, the if condition would be true if:

  • The user sent a POST to / with foo set to bar (either in a form or in JSON)
  • Or the user sent a GET to /?foo=bar

This API is easier to implement and arguably easier to understand.


My preference at this point is proposal 2.

That said, both of these proposals are just straw-man designs to start a discussion. I believe neither of these is ready to implement at this point.


Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.

If you’d like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:84
  • Comments:25 (1 by maintainers)

github_iconTop GitHub Comments

29reactions
shrilcommented, Jan 13, 2020

Any progress on this?

18reactions
davidefioccocommented, Feb 25, 2021

As a temporary workaround, piggybacking on FastAPI may be a solution to support HTTP and have OpenAPI docs as suggested in https://github.com/streamlit/streamlit/issues/439#issuecomment-635796911. I understand that this adds complexity as it needs two services (streamlit and FastAPI server) to be running in parallel, but I am sharing it here anyway as it may be interesting for some to explore for the time being!

https://davidefiocco.github.io/streamlit-fastapi-ml-serving (video) https://github.com/davidefiocco/streamlit-fastapi-model-serving/

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to compose a HTTP request with a custom HTTP method ...
I need to request ressources which are bound to custom HTTP methods on server side. I know about the fire fox plugin RESTClient...
Read more >
How to make custom HTTP requests in Python - Educative.io
We will make use of the requests module to make custom HTTP requests. ... Next, we call the HTTP request method we want...
Read more >
HTTP headers - MDN Web Docs - Mozilla
Custom proprietary headers have historically been used with an X- prefix, ... Lists the set of HTTP request methods supported by a resource....
Read more >
Custom HTTP Methods == More Flexibility and Autonomy
Postman's gRPC support started out with a single feature request in GitHub that received hundreds of upvotes, thumbs-ups, and positive reactions ...
Read more >
Requests with custom HTTP headers - Progress Documentation
If a service returns responses in multiple supported formats (JSON, XLM, CSV). · If the default Accept header, application/json , is not accepted...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found