Overview
Comment: | [server] code cleaning (pylint) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | server |
Files: | files | file ages | folders |
SHA3-256: |
0c8e86b8c79864983363ba5d9278e4d5 |
User & Date: | olr on 2019-05-11 10:48:05 |
Other Links: | manifest | tags |
Context
2019-05-11
| ||
10:55 | [build] code cleaning (pylint) check-in: dad850cc6c user: olr tags: trunk, build | |
10:48 | [server] code cleaning (pylint) check-in: 0c8e86b8c7 user: olr tags: trunk, server | |
10:19 | [core][py][bug] fix displayRules check-in: ee0cb1670d user: olr tags: trunk, core | |
Changes
Modified grammalecte-server.py from [4958939df5] to [ebda6f5998].
1 2 3 4 5 6 7 8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + + + + - + | #!/usr/bin/env python3 """ Grammalecte server: grammar checker """ import sys import argparse import json import traceback import time |
︙ | |||
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | + + + + - + + - + + + - + + - + | """ TESTPAGE = False def genUserId (): "generator: returns id as string for users" i = 0 while True: yield str(i) i += 1 app = Bottle() # GET @app.route("/") def mainPage (): "page for testing purpose" if TESTPAGE: return HOMEPAGE #return template("main", {}) return SADLIFEOFAMACHINE @app.route("/get_options/fr") def listOptions (): "returns grammar options in a text JSON format" sUserId = request.cookies.user_id dOptions = dUser[sUserId]["gc_options"] if sUserId and sUserId in dUser else dGCOptions return '{ "values": ' + json.dumps(dOptions) + ', "labels": ' + json.dumps(gce.getOptionsLabels("fr"), ensure_ascii=False) + ' }' # POST @app.route("/gc_text/fr", method="POST") def gcText (): "parse text and returns errors in a JSON text format" #if len(lang) != 2 or lang != "fr": # abort(404, "No grammar checker available for lang “" + str(lang) + "”") bComma = False dOptions = None sError = "" if request.cookies.user_id: if request.cookies.user_id in dUser: dOptions = dUser[request.cookies.user_id].get("gc_options", None) response.set_cookie("user_id", request.cookies.user_id, path="/", max_age=86400) # we renew cookie for 24h else: response.delete_cookie("user_id", path="/") if request.forms.options: try: dOptions = dict(dGCOptions) if not dOptions else dict(dOptions) dOptions.update(json.loads(request.forms.options)) |
︙ | |||
237 238 239 240 241 242 243 | 249 250 251 252 253 254 255 256 257 258 259 | - - - + + + + | if xArgs.opt_on or xArgs.opt_off: dOpt = {} if xArgs.opt_on: dOpt = { opt:True for opt in xArgs.opt_on } if xArgs.opt_off: dOpt.update({ opt:False for opt in xArgs.opt_off }) |