Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'socket': 0.04; '(python': 0.05; 'python': 0.08; '21,': 0.09; 'function:': 0.09; 'files.': 0.09; 'am,': 0.12; 'server,': 0.12; 'def': 0.14; 'mon,': 0.15; 'code?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'server?': 0.16; 'worse,': 0.16; '\xa0what': 0.16; 'wrote:': 0.18; 'received:209.85.210.174': 0.18; 'received :mail-iy0-f174.google.com': 0.18; 'subject:Questions': 0.18; 'accepting': 0.19; 'header:In-Reply-To:1': 0.23; 'code': 0.25; 'code.': 0.26; 'pass': 0.28; 'message-id:@mail.gmail.com': 0.29; 'server': 0.30; 'environment': 0.30; 'fairly': 0.30; 'user.': 0.30; 'nov': 0.31; 'andrew': 0.32; 'does': 0.32; 'sort': 0.32; 'to:addr:python-list': 0.32; 'it.': 0.33; 'however,': 0.34; 'running': 0.35; 'question': 0.35; 'file': 0.36; 'example,': 0.36; 'disk': 0.36; 'http': 0.36; 'list,': 0.37; 'easiest': 0.38; 'run': 0.38; 'received:google.com': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'form,': 0.38; 'subject: (': 0.39; 'subject:: ': 0.39; 'or,': 0.39; 'perform': 0.39; 'to:addr:python.org': 0.39; 'files': 0.40; 'received:209': 0.40; 'user': 0.40; 'your': 0.61; 'back': 0.62; '2011': 0.62; 'accepts': 0.64; 'internet': 0.64; 'protect': 0.77; 'malicious': 0.84; 'uploads': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=LEn6T/p3NQQHNerMQYgqzzNp6/M+QSikO6XFP+4sraw=; b=Umza7lppR+YoNoLL6vWGqvFPBipzOE9zHCgHSuHPSc3baUZUZLDKkfRUaNseLqNNvb hp9OmZqtMqVaiC3QnqtHQ+kVV4f8gxHUsVPRQclzSlgW8on8WgWF8kf2uK0af9QbXmh9 bCxqKUFK8qcv0rbABBZILVhzbygA8gmuMzqLE= MIME-Version: 1.0 In-Reply-To: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Date: Mon, 21 Nov 2011 08:34:28 +1100 Subject: Re: Server Questions (2 of them) From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321824872 news.xs4all.nl 6976 [2001:888:2000:d::a6]:53026 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15967 On Mon, Nov 21, 2011 at 7:02 AM, Andrew wrote= : > Hello List, > > How to do you create a server that accepts a set of user code? > > For example, > > I would like to send this function: > def addition(x,y): > =A0 return x+y > and have the socket server perform the operation and send is back to > the end user. > > Question 2: > On that same server, I want a user to be able to pass a file to the > server along with code. =A0What is the best way to pass file to the > server? The easiest way is to write an HTTP server (Python has some tools that will make this easy) and use an HTML form, which can do file uploads as well as accept keyed-in code. However, you will run into some fairly major security issues. You're accepting code across the internet and running it. Python does not protect you against malicious users reading files from your hard disk or, worse, modifying those files. This sort of thing can ONLY be used in a trusted environment - a local network on which you know everything that's happening. ChrisA