forked from mrlan/EnglishPal
				
			Compare commits
	
		
			3 Commits 
		
	
	
		
			Bug585-zha
			...
			improvment
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 1ce6dcf41b | |
|  | 3ad9ab7351 | |
|  | fa3012920e | 
|  | @ -11,6 +11,7 @@ from Article import * | |||
| import Yaml | ||||
| from user_service import userService | ||||
| from account_service import accountService | ||||
| from wordCMD import show_bp | ||||
| from admin_service import adminService, ADMIN_NAME | ||||
| app = Flask(__name__) | ||||
| app.secret_key = 'lunch.time!' | ||||
|  | @ -19,6 +20,7 @@ app.secret_key = 'lunch.time!' | |||
| app.register_blueprint(userService) | ||||
| app.register_blueprint(accountService) | ||||
| app.register_blueprint(adminService) | ||||
| app.register_blueprint(show_bp) | ||||
| 
 | ||||
| path_prefix = '/var/www/wordfreq/wordfreq/' | ||||
| path_prefix = './'  # comment this line in deployment | ||||
|  |  | |||
|  | @ -0,0 +1,9 @@ | |||
| <h1>Here are {{ name }}'s words:</h1> | ||||
| <table border="2"> | ||||
|   <tr> | ||||
|     <th>WORDS</th> | ||||
|   </tr> | ||||
|   {% for word in results %} | ||||
|     <tr><td>{{ word }}</td></tr> | ||||
|   {% endfor %} | ||||
| </table> | ||||
|  | @ -0,0 +1,33 @@ | |||
| from flask import Flask, request, Blueprint, render_template | ||||
| from UseSqlite import InsertQuery, RecordQuery | ||||
| 
 | ||||
| TKTK = 'token' # set token | ||||
| 
 | ||||
| show_bp = Blueprint( | ||||
|     'site', | ||||
|     __name__, | ||||
| ) | ||||
| 
 | ||||
| # The following function is replaced by the template show.html.  | ||||
| # And can be safely deleted. | ||||
| # def make_html_paragraph(s): # build the word's table | ||||
| #     if s.strip() == '': | ||||
| #         return '' | ||||
| #     lst = s.split(',') | ||||
| #     word = lst[1].strip() | ||||
| #     result = '<tr><td>' + word + '</td></tr>' | ||||
| #     return result | ||||
| 
 | ||||
| @show_bp.route('/show/<name>/')  # set route for show page <name> means the var name to search | ||||
| def show(name): | ||||
|     token = request.args.get("token") | ||||
|     # when token is wrong | ||||
|     if token != TKTK: | ||||
|         return "token is wrong, please try again" | ||||
|      | ||||
|     rq = RecordQuery('./static/wordfreqapp.db') | ||||
|     # search the user's words in db | ||||
|     rq.instructions_with_parameters("SELECT * FROM words WHERE user = ?", (name,)) | ||||
|     rq.do_with_parameters() | ||||
|     results = [row.split(",")[1].strip() for row in rq.format_results().split("\n\n")] | ||||
|     return render_template("show.html", name=name, results=results) | ||||
		Loading…
	
		Reference in New Issue