Created
August 31, 2017 20:43
-
-
Save gnardini/240687da6e5096b3f0b11e3a63a7d953 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
import os | |
from os.path import expanduser | |
app = Flask(__name__) | |
def expand(path): | |
if path.startswith('~'): | |
path = path[1:] | |
path = expanduser("~") + path | |
return path | |
@app.route("/fetch") | |
def fetch_shows(): | |
dir = request.args.get('directory') | |
dir = expand(dir) | |
dirs = filter(lambda x: not x.startswith('.'), os.listdir(dir)) | |
return str(list(dirs)) | |
@app.route("/open") | |
def open(): | |
file = request.args.get('file') | |
file = expand(file) | |
# os.startfile(file) | |
os.system('open %s' % file) | |
return "{\"result\": \"OK\"}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment