forked from WheatonCS/Lexos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.txt
68 lines (47 loc) · 2.06 KB
/
module.txt
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
####################################################################################
# This is just a simple module which saves a string as a file in the file manager. #
# It is a useful model for development purposes. #
####################################################################################
##########################
### Insert in lexos.py ###
##########################
@app.route("/module", methods=["GET", "POST"]) # Tells Flask to load this function when someone is at '/module'
def module():
"""
Generic module for saving text stored as a variable to the file manager. It mostly just illustrates how
to access the file manager.
"""
fileManager = managers.utility.loadFileManager()
if request.method == "GET":
# "GET" request occurs when the page is first loaded.
# Get a dictionary of the currently active files' labels.
labels = fileManager.getActiveLabels()
message = "Submit to load file"
return render_template('module.html', message=message)
if request.method == "POST":
# "POST" request occur when html form is submitted
labels = fileManager.getActiveLabels()
# This variable stores some text to be added as a new file to the file manager
doc = "Whan that Aprill with his shoures sote"
fileName = "NewFile.txt"
# Save the file to the file manager
fileManager.addUploadFile(doc, fileName)
message = "File saved!"
# Save the file manager
managers.utility.saveFileManager(fileManager)
return render_template('module.html', message=message)
###################
### module.html ###
###################
{% extends "base_visualize.html" %}
{% set active_page = 'module' %}
{% block head %}
{% endblock %}
{% block title %}module{% endblock %}
{% block options %}
<legend>Generic Module</legend>
<p>{{message}}</p>
{% endblock %}
{% block submit %}
<input class="bttn bttn-action" id="submit" type="submit" value="Submit" style="float: left; margin-right: 10px; "/>
{% endblock %}