-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
45 lines (37 loc) · 937 Bytes
/
main.py
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
from flask import Flask
from flask import render_template
from flask import request
from flask_cors import *
import sqldb
import json
app=Flask(__name__)
CORS(app,supports_credentials=True)
@app.route('/')
def index():
return render_template('file.html')
@app.route('/addfile',methods=['POST', 'GET'])
def addFile():
file_url=request.form['url']
sqldb.insert(file_url)
return json.dumps('success')
@app.route('/getfile')
def getFile():
return json.dumps(sqldb.getData())
@app.route('/download',methods=['POST', 'GET'])
def download():
if request.method=='POST':
id=request.form['id']
if not id:
id=0
else:
id=int(id)
else:
id=0
return sqldb.download(id)
@app.route('/deletefile',methods=['POST', 'GET'])
def deleteFile():
id=request.form['id']
sqldb.delete(id)
return json.dumps('success')
if __name__=='__main__':
app.run()