-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathserver.py
More file actions
27 lines (24 loc) · 843 Bytes
/
server.py
File metadata and controls
27 lines (24 loc) · 843 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
from flask import Flask
app = Flask(__name__)
import os
import glob
import shutil
from flask import request
@app.route('/generate')
def data():
# here we want to get the value of user (i.e. ?user=some-value)
username = request.args.get('user')
if not username.isalpha():
return "You need to enter a username that is all letters."
if len(username)<2:
return "Your username is too short"
newdir = "ipython/user_" + username
if os.path.exists(newdir):
return "This username already exists"
source_ipython = "source_ipython"
os.makedirs(newdir)
for filename in glob.glob(os.path.join(source_ipython, '*')):
shutil.copy(filename, newdir)
return "Thanks. There is now a folder for user %s. Press back!" % username
if __name__ == "__main__":
app.run(host= '0.0.0.0')