diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/englishpal.iml b/.idea/englishpal.iml
new file mode 100644
index 0000000..8b8c395
--- /dev/null
+++ b/.idea/englishpal.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..f6104af
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..31b95c5
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/main.py b/app/main.py
index 1356f12..61e02a4 100644
--- a/app/main.py
+++ b/app/main.py
@@ -269,7 +269,11 @@ def user_mark_word(username):
else:
return 'Under construction'
-
+@app.route("///del", methods=['GET', 'POST'])
+def deleteword(username,word):
+ user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
+ pickle_idea2.deleteRecord(user_freq_record,word)
+ return redirect(url_for('userpage', username=username))
@app.route("/", methods=['GET', 'POST'])
def userpage(username):
@@ -345,9 +349,9 @@ def userpage(username):
freq = x[1]
if isinstance(d[word], list): # d[word] is a list of dates
if freq > 1:
- page += ' %s (%d)
\n' % (youdao_link(word), word, '; '.join(d[word]), freq)
+ page += ' %s(%d) 删除
\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word)
else:
- page += ' %s (%d)
\n' % (youdao_link(word), word, '; '.join(d[word]), freq)
+ page += ' %s(%d) 删除
\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word)
elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format.
page += '%s%d\n' % (youdao_link(word), word, freq)
diff --git a/app/pickle_idea2.py b/app/pickle_idea2.py
index 91a5b11..4055fc4 100644
--- a/app/pickle_idea2.py
+++ b/app/pickle_idea2.py
@@ -25,6 +25,15 @@ def lst2dict(lst, d):
else:
d[word] += dates
+def deleteRecord(path,word):
+ with open(path, 'rb') as f:
+ db = pickle.load(f)
+ try:
+ db.pop(word)
+ except KeyError:
+ print("sorry")
+ with open(path, 'wb') as ff:
+ pickle.dump(db, ff)
def dict2lst(d):
if len(d) > 0: