Transitioning from Linux to Windows

Pavol Lisy pavol.lisy at gmail.com
Sun Jun 4 05:06:03 EDT 2017


If I understand well then you like to have simple quick solution
without need to learn much.

And that you don't need to support big traffic...

Maybe cherrypy ( http://cherrypy.org/ ) is what you like to look at.

Probably this is good enough on your ubuntu:

    sudo apt-get install python3-cherrypy3

You could simply run:
    python3 cherry_test.py  # source code bellow

and open web page http://localhost:8080/ in your browser.

####  cherry_test.py
import string
import os
import os.path

import cherrypy
from cherrypy.lib import static

localDir = os.path.dirname(__file__)
absDir = os.path.join(os.getcwd(), localDir)

class StringGenerator(object):
    @cherrypy.expose
    def index(self):
        return """<html>
          <head></head>
          <body>
            <form method="get" action="generate">
              <input type="text" value="test.txt" name="filename" />
              <button type="submit">Give it now!</button>
            </form>
          </body>
        </html>"""

    @cherrypy.expose
    def generate(self, filename='test.txt'):
        with open(filename, 'w') as f:
            f.write('test')  # generate simple output file
        path = os.path.join(absDir, filename)
        return static.serve_file(path, 'application/x-download',
                                 'attachment', os.path.basename(path))


if __name__ == '__main__':
    cherrypy.quickstart(StringGenerator())
#######

Simple isn't it?

But don't forget to think about security! :)

On 6/3/17, chitturk at uah.edu <chitturk at uah.edu> wrote:
> I am looking for suggestions, ideas.
>
> I have developed python (3.6.x, 2.7.x) scripts that run well as a user on an
> ubuntu/16.04 system - the scripts look for files, parses the files,
> assembles an output for the user.
>
> I first cd into a particular directory on the system (where I know the files
> exist) and run the script - the final result is in my working directory.
>
> What I am now trying to do is ... figure out the least painful way to have
> other users do the same - BUT sitting in front of a Windows desktop (7 or
> 10).
>
> Ideally, I would like to set up the user on their Windows 7/10 system so
> that they can "login" to the ubuntu system (say putty) - change working
> directory (to where desired) - run the script (on the ubuntu system) - and
> scp the file back to the windows desktop.
>
> ("porting" the ubuntu script to anaconda(3) on the windows desktop IS
> possible (but it has not been as easy as I had hoped!) (django and programs
> like that do seem to provide a "GUI" to have python scripts run on
> ubuntu/systems - but the setup looks mysterious/complicated (to me anyway))
>
> I stumbled onto "paramiko" - is that a possible answer?
>
> Any suggestion/ideas would be greatly appreciated!
>
> (I am perfectly willing to stick to 3.6.x, unless there is a clean/easy
> solution using 2.7.x)
>
> krishnan
> --
> https://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list