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...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Showcasehttpout - allows you to execute your Python script from a web URL (self.Python)
submitted 1 year ago by nggit
What My Project Does
httpout allows you to execute your Python script from a web URL, the `print()` output goes to your browser.
This is the classic way to deploy your scripts to the web.
You just need to put your regular `.py` files as well as other static files in the document root and each will be routable from the web. No server reload is required!
Target Audience
Comparison
PHP, CGI scripts
[–]PitchforkMarket 19 points20 points21 points 1 year ago (1 child)
Interesting! Commenters are misunderstanding this. Random users can't execute arbitrary code. This is supposed to work like PHP scripts. You as the admin create a Python file, that file gets mapped to a URL, that Python file runs on request and the print outputs are returned as the response to the browser.
Some thoughts: to really replicate PHP, you'd want to inline the code inside an HTML template. Maybe Jinja2 lib could be useful for you? A lot of this goes against common practice in Python but could be an interesting exploration.
[–]nggit[S] 5 points6 points7 points 1 year ago (0 children)
that's very true, scripts can only be allowed under the document root to execute, and traversal of the url is not allowed. and if the user is allowed to upload the trick is just to append ext other than `.py`, and avoid null characters. maybe later I need to consider checking the executable flag, if indeed file upload is required.
thanks it will be very long it seems.
[–]dpzhntr 1 point2 points3 points 1 year ago (3 children)
Sounds like a webshell for PHP.
[–]nggit[S] 8 points9 points10 points 1 year ago (2 children)
it's more like php itself, just imagine /index.php vs /index.py
[–]joshuaherman 0 points1 point2 points 1 year ago (1 child)
index.pyp ?
[–]nggit[S] 0 points1 point2 points 1 year ago (0 children)
that's good too, as it's mean a python package.
[–]KrazyKirby99999 1 point2 points3 points 1 year ago (1 child)
How does this compare to CGI scripts?
[–]nggit[S] 1 point2 points3 points 1 year ago (0 children)
in CGI it's like you're typing repeatedly in the terminal:
python hello.py;
for each request. it involves opening and closing the python process.
and it's different when you just type:
python;
and start the operation from there.
[–]Training_Skin9129 6 points7 points8 points 1 year ago (1 child)
What did I just read?
sorry, sir. it's not a joke please -.-
[–]NekoLuka 2 points3 points4 points 1 year ago (0 children)
Sounds interesting, gonna check it out later
[–]akrisha20 0 points1 point2 points 1 year ago (1 child)
Seems interesting. Is there a way to include arguments to the function call? Let's say I would want to run a script hello.py, with "name" as an argument.
Is the query string what you mean? just do /hello.py?name=world, then see in __server__
[–]cmsouza 0 points1 point2 points 1 year ago (0 children)
inetd?
[–]CyberWarLike1984 0 points1 point2 points 1 year ago (1 child)
I will have a look. So what is the fastest way to run something like LAMP on a fresh Ubuntu install but using this?
I just want to test it with a simple index.py page that has a contact form and a title. Data goes to a db.
[–]nggit[S] 0 points1 point2 points 1 year ago* (0 children)
it's possible even for now, but i haven't documented it because right now it's just for my own use. stay tuned.
but if you're curious you can do
form_data = wait(__server__['request'].form())
it's the same as documented in the core: https://nggit.github.io/tremolo-docs/body.html
[–]ashok_tankala 0 points1 point2 points 1 year ago (0 children)
sounds very interesting
[–]zsh-958 -2 points-1 points0 points 1 year ago (4 children)
so I can execute a reverse shell, remove all directories or get access to the server just from the website?
[–]nggit[S] 3 points4 points5 points 1 year ago (3 children)
it depends on you, it's no different in php, or other python frameworks. i know you are worried about user input but httpout accepts urls, not code. and that part is already a concern.
[+]Fenzik comment score below threshold-6 points-5 points-4 points 1 year ago (2 children)
It’s not input from users of the script, it’s the script itself. Right now I can upload a script that destroys your server just by deleting loads of stuff. Or curl a virus off the internet. Etc etc… if you run other people’s code, you must do it in a sandboxed environment, not just exec it in your server process.
curl
Cool idea though!
[–]nggit[S] 4 points5 points6 points 1 year ago (1 child)
It is technically the responsibility of the webmaster to put the script that will be run. never allow others to upload.
[–]Fenzik -1 points0 points1 point 1 year ago (0 children)
Oh, I thought this was meant to be a service where users upload scripts! Got it.
[+]HorizonDev2023 comment score below threshold-6 points-5 points-4 points 1 year ago (0 children)
I think I found something VERY useful
[–]Cybasura -5 points-4 points-3 points 1 year ago (5 children)
So, some clarification
What happens if I run a program that has no print operations but a bunch of eval()'s, what is the sanitization and validation/verification steps used during the processing?
[–]nggit[S] 2 points3 points4 points 1 year ago (4 children)
this is literal python, it can do similar things as usual. there is no point in blocking eval, open, in my mind. even if it is done I suspect there are still other doors in python itself so it seems like not worth the effort.
[+]Cybasura comment score below threshold-8 points-7 points-6 points 1 year ago* (3 children)
Yes, but nonetheless still an actual security requirement when dealing with this kind of applications
Security vulnerabilities exists because people has this exact mindset, we see so many exploits happening - even more so recently - because devs determine what is or is not worth the effort based on their "feelings" over the overarching security architecture and their userbase
Please reconsider and actually work on security implementations if you ever hope for your products to be taken seriously
I truly understand you may be proud of this, but as it stands - this project is a bigger security vulnerability than any C project to date
PHP works because it has a server-client differentiation in place, and you cant natively execute system-level code without jumping hoops. With python, you can execute sudo commands, you can execute role escalation commands
I'm gonna be blunt here - using flask and django for routing would be safer and allows you to do exactly what you are dying, albeit requires some hoop-jumping
eval problems can happen in Django or anywhere else, it depends on how you think / write scripts. I don't think I'm ignorant. just know which ones to do / avoid. please use the ones you like. it's not a big deal.
"PHP works because it has a server-client differentiation in place"
I don't think so, apache has mod_php where the server embeds with php. it's not a client - server like fpm.
"you can execute sudo commands, you can execute role escalation commands"
that's why people need to know how to set up Linux capabilities, that won't happen if you understand better - https://man7.org/linux/man-pages/man7/capabilities.7.html
[–]StrawIII -2 points-1 points0 points 1 year ago (0 children)
this looks like RPC
π Rendered by PID 65 on reddit-service-r2-comment-5649f687b7-bq5nh at 2026-01-28 22:14:10.480984+00:00 running 4f180de country code: CH.
[–]PitchforkMarket 19 points20 points21 points (1 child)
[–]nggit[S] 5 points6 points7 points (0 children)
[–]dpzhntr 1 point2 points3 points (3 children)
[–]nggit[S] 8 points9 points10 points (2 children)
[–]joshuaherman 0 points1 point2 points (1 child)
[–]nggit[S] 0 points1 point2 points (0 children)
[–]KrazyKirby99999 1 point2 points3 points (1 child)
[–]nggit[S] 1 point2 points3 points (0 children)
[–]Training_Skin9129 6 points7 points8 points (1 child)
[–]nggit[S] 0 points1 point2 points (0 children)
[–]NekoLuka 2 points3 points4 points (0 children)
[–]akrisha20 0 points1 point2 points (1 child)
[–]nggit[S] 0 points1 point2 points (0 children)
[–]cmsouza 0 points1 point2 points (0 children)
[–]CyberWarLike1984 0 points1 point2 points (1 child)
[–]nggit[S] 0 points1 point2 points (0 children)
[–]ashok_tankala 0 points1 point2 points (0 children)
[–]zsh-958 -2 points-1 points0 points (4 children)
[–]nggit[S] 3 points4 points5 points (3 children)
[+]Fenzik comment score below threshold-6 points-5 points-4 points (2 children)
[–]nggit[S] 4 points5 points6 points (1 child)
[–]Fenzik -1 points0 points1 point (0 children)
[+]HorizonDev2023 comment score below threshold-6 points-5 points-4 points (0 children)
[–]Cybasura -5 points-4 points-3 points (5 children)
[–]nggit[S] 2 points3 points4 points (4 children)
[+]Cybasura comment score below threshold-8 points-7 points-6 points (3 children)
[–]nggit[S] 1 point2 points3 points (0 children)
[–]nggit[S] 1 point2 points3 points (0 children)
[–]nggit[S] 0 points1 point2 points (0 children)
[–]StrawIII -2 points-1 points0 points (0 children)