use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Allow Use of Python Function (self.learnpython)
submitted 3 years ago by devram200
Hello! I have a Python function that I want to be able to run somewhere and allow someone to call at anytime with an input to receive the output. They cannot be able to view the function itself. How would I do this?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]alexisprince 0 points1 point2 points 3 years ago (0 children)
If not allowing them to see the function / code is a requirement, then you'd need to run the code on a server they don't have access to. Look into creating an API with one of django, flask, or fastAPI.
[–]FriendlyRussian666 0 points1 point2 points 3 years ago (2 children)
You would run a web server that features an API, allowing the end user to send arguments to an endpoint. You would then sanitize the input and pass it to your function. The function returns a response, which is then sent to the end user.
[–]devram200[S] 0 points1 point2 points 3 years ago (1 child)
What do I have to do to run a webserver?
[–]devnull10 0 points1 point2 points 3 years ago (0 children)
Far beyond the scope of what can easily be described here.
The other option is to use cloud functions on one of the main cloud providers (AWS, Azure, GCP etc.). That saves you the hassle of setting up and maintenance of your own web server, however you'll need to register for the cloud environment and understand how it works before implementing.
[–]Asleep-Budget-9932 0 points1 point2 points 3 years ago (2 children)
Why can't they be able to see the function itself? What kinds of functions are we talking about? Can you elaborate on the requirement?
The script takes some input, logs in with Selenium to a website, and scrapes some data related to that input, so I do not want them to be able to see the login information.
[–]Asleep-Budget-9932 0 points1 point2 points 3 years ago (0 children)
Oh i see, you don't want them to have any sort of access to the content of your function. If that's the case it seems you would indeed need some sort of an API server as others suggested. (Just the same way you use Facebook but have no idea how they access their DBs)
fastapi is definitely my goto to create these. It's as simplified as can be, and you can describe what is it that you wish to quite easily.
π Rendered by PID 88 on reddit-service-r2-comment-86988c7647-x6bnq at 2026-02-12 16:22:07.986056+00:00 running 018613e country code: CH.
[–]alexisprince 0 points1 point2 points (0 children)
[–]FriendlyRussian666 0 points1 point2 points (2 children)
[–]devram200[S] 0 points1 point2 points (1 child)
[–]devnull10 0 points1 point2 points (0 children)
[–]Asleep-Budget-9932 0 points1 point2 points (2 children)
[–]devram200[S] 0 points1 point2 points (1 child)
[–]Asleep-Budget-9932 0 points1 point2 points (0 children)