-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (32 loc) · 882 Bytes
/
app.py
File metadata and controls
47 lines (32 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import atexit
import subprocess
from json import JSONEncoder
from flask import request
from flask import Flask, render_template
from client import *
app = Flask(__name__)
class MyEncoder(JSONEncoder):
def default(self, o):
return o.__dict__
@app.route('/')
def init():
return render_template('index.html')
@app.route('/list/', methods=['GET'])
def files_server():
return list_files()
@app.route('/get/', methods=['GET'])
def download():
filename = request.args.get('filename')
return str(get_file(filename))
@app.route('/put/', methods=['GET'])
def upload():
filename = request.args.get('filename')
a = put_file(filename)
return str(a)
@app.route('/getclient/', methods=['GET'])
def files_client():
return get_client_files()
if __name__ == '__main__':
p = subprocess.Popen(['python', 'server.py'])
atexit.register(lambda: p.kill())
app.run(debug=False)