How to make a file transfer program in python
<p>The title might not be relevant for my question becuase I don't actually want a wireless file transfering script, I need a file manager type.</p>

<p>I want something with which I can connect my phone with my pc (eg: hotspot and wifi) and then I would like to show text file browser (I have the code for that) by sending lists of all files and folders using <code>os.listdir()</code>, whenever the selected option is a file (<code>os.path.isdir() == False</code>), I would like to transfer the file and run it(like: picture, video, etc).</p>

<p>The file Browser code which I wrote runs on windows and also Android (after making a few changes) using <code>qpython</code>. My code is</p>

<pre><code>import os
def FileBrowser(cwd = os.getcwd()):
  while True:
    if cwd[-1:] != "\\":
      cwd = cwd + "\\"
    files = os.listdir(cwd)
    count = 1
    tmpp = ""
    print("\n\n" + "_"*50 +"\n\n")
    print(cwd + "\n")
    for f in files:
      if os.path.isdir(cwd + f) == True:
        s1 = str(count) + ". " + f
        tmps1 = 40 - (len(s1)+5)
        t2 = int(tmps1/3)
        s1 = s1 + " " * t2 + "-" * (tmps1 - t2)
        print(s1 + "&lt;dir&gt;")
      else:
        print(str(count) + ". " + f + tmpp)
      count = count + 1
    s = raw_input("Enter the file/Directory: ")
    if s == "...":
      tmp1 = cwd.count("\\")
      tmp2 = cwd.rfind("\\")
      if tmp1 &gt; 1:
        cwd = cwd[0:tmp2]
        tmp2 = cwd.rfind("\\")
        cwd = cwd[0:tmp2+1]
        continue
      else:
        continue
    else:
      s = int(s) - 1
    if os.path.isdir(cwd + files[s]) == True:
      cwd = cwd + files[s] + "\\"
      continue
    else:
      f1 = files[s]
      break
  return f1
def main():
  fb = FileBrowser()
main()
</code></pre>

<p>A very naive approach using Python is to go to the root of the directory you want to be served and use:</p>

<pre><code>python -m SimpleHTTPServer
</code></pre>

<p>The connect to it on port 8000.</p>

python