Compare commits

..

No commits in common. "19ea14b38cf2fd7dcbab76b3da8bc743a4edb0c8" and "909119b5878b70ed70fd9f82e60f867cf7a5ba6b" have entirely different histories.

2 changed files with 0 additions and 34 deletions

View File

@ -1,31 +0,0 @@
from flask import *
from flask_httpauth import HTTPTokenAuth
from Article import load_freq_history
path_prefix = '/var/www/wordfreq/wordfreq/'
path_prefix = './' # comment this line in deployment
apiService = Blueprint('site',__name__)
auth = HTTPTokenAuth(scheme='Bearer')
tokens = {
"token": "token",
"secret-token": "lanhui" # token, username
}
@auth.verify_token
def verify_token(token):
if token in tokens:
return tokens[token]
@apiService.route('/api/mywords') # HTTPie usage: http -A bearer -a secret-token http://127.0.0.1:5000/api/mywords
@auth.login_required
def show():
username = auth.current_user()
word_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
d = load_freq_history(word_freq_record)
return jsonify(d)

View File

@ -10,11 +10,9 @@ import Yaml
from user_service import userService from user_service import userService
from account_service import accountService from account_service import accountService
from admin_service import adminService, ADMIN_NAME from admin_service import adminService, ADMIN_NAME
from api_service import apiService
import os import os
from translate import * from translate import *
app = Flask(__name__) app = Flask(__name__)
app.secret_key = os.urandom(32) app.secret_key = os.urandom(32)
@ -22,7 +20,6 @@ app.secret_key = os.urandom(32)
app.register_blueprint(userService) app.register_blueprint(userService)
app.register_blueprint(accountService) app.register_blueprint(accountService)
app.register_blueprint(adminService) app.register_blueprint(adminService)
app.register_blueprint(apiService)
path_prefix = '/var/www/wordfreq/wordfreq/' path_prefix = '/var/www/wordfreq/wordfreq/'
path_prefix = './' # comment this line in deployment path_prefix = './' # comment this line in deployment