-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebApp.py
More file actions
44 lines (35 loc) · 1.03 KB
/
Copy pathwebApp.py
File metadata and controls
44 lines (35 loc) · 1.03 KB
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
import random
import string
from bottle import route, run, static_file
@route('/hello')
def hello():
return "Hello World!"
@route('/')
def hello():
filename='index.html'
return static_file(filename, root='/')
run(host='localhost', port=8080, debug=True)
def generateFilename () :
return "".join( [random.choice(string.letters) for i in xrange(6)] )
#@route('/')
def server_index():
return "HI";
# filename='index.html'
# return static_file(filename, root='/')
@route('/design', method='POST')
def upload_design():
upload = request.files.get('upload')
filename = "res/design"+generateFilename()+".jpg"
upload.save(filename)
return filename
@route('/image', method='POST')
def upload_design():
upload = request.files.get('upload')
filename = "res/image"+generateFilename()+".jpg"
upload.save(filename)
return filename
@route('/preview', method='POST')
def request_preview():
pass
if __name__ == '__main__':
run(host='localhost', port=8080)