| 177 | |
| 178 | @tornado.web.authenticated |
| 179 | def get(self): # download user phrase file |
| 180 | user_phrase_file = os.path.join(config_dir, "chewing.sqlite3") |
| 181 | if not os.path.exists(user_phrase_file): |
| 182 | raise HTTPError(404) |
| 183 | self.set_header("Content-Type", "application/force-download") |
| 184 | self.set_header("Content-Disposition", "attachment; filename=chewing.sqlite3") |
| 185 | with open(user_phrase_file, "rb") as f: |
| 186 | try: |
| 187 | self.write(f.read()) |
| 188 | f.close() |
| 189 | self.finish() |
| 190 | return |
| 191 | except: |
| 192 | raise HTTPError(404) |
| 193 | raise HTTPError(500) |
| 194 | |
| 195 | @tornado.web.authenticated |
| 196 | def post(self): # upload file |