示例#1
0
文件: server.py 项目: simplerr/TDDD97
def init_db():
	database_helper.init_db()
	return 'init_db()'
示例#2
0
# This module handles incoming server requests. Core back-end.

from flask import Flask, request, redirect, url_for
from geventwebsocket import WebSocketServer, WebSocketError
from geventwebsocket.handler import WebSocketHandler
from passlib.hash import sha256_crypt
from functools import wraps
import json, re, urllib

# Local modules
import database_helper as db
import websocket_helper as sockets

app = Flask(__name__, static_url_path='')

db.init_db(app)

#--- Decorators ---#


# Check if user signed in
def is_signed_in(f):
    @wraps(f)
    def wrap(*args, **kwargs):
        token = request.headers.get('token')
        if token and db.get_email_by_token(token):
            return f(*args, **kwargs)
        else:
            return json.dumps({
                'success': False,
                'message': "You are no longer signed in."
def init():
    database_helper.init_db(app);
    return render_template('hello.html',message = "database initiated")
示例#4
0
def init_db():
	database_helper.init_db()
	return 'init_db()'
示例#5
0
def init_database():
    with app.app_context():
        database_helper.init_db(DATABASE)
示例#6
0
def test():
    database_helper.init_db()
    return "open DB"
示例#7
0
def initdb_command():
    database_helper.init_db(app)
    print("db initialized")
示例#8
0
def hello():
    database_helper.init_db()

    return "world, hello"
示例#9
0
def main():
    db = database_helper.get_db()
    database_helper.init_db()
    return app.send_static_file('client.html')
示例#10
0
def main():
    db = database_helper.get_db()
    database_helper.init_db()
    #return render_template('static/client.html')
    return app.send_static_file('client.html')
示例#11
0
def init_twidder():
    db.init_db()  ##initiates database with schema.sql script
    print("Initiation done!")
示例#12
0
            country):
    database_helper.sign_up(email=email, password=password,
                            firstname=firstname, familyname=familyname,
                            gender=gender, city=city, country=country)
    return "SIGN UP"

def sign_out(token):
    raise NotImplementedError

def change_password(token, old_password,
                    new_password):
    raise NotImplementedError

def get_user_data_by_token(token):
    raise NotImplementedError

def get_user_data_by_email(token, email):
    raise NotImplementedError

def get_user_messages_by_token(token):
    raise NotImplementedError

def get_user_messages_by_email(token, email):
    raise NotImplementedError

def post_message(token, message, email):
    raise NotImplementedError

if __name__ == "__main__":
    database_helper.init_db()
    app.run(debug=True)
示例#13
0
def doinitdb():
    database_helper.init_db()
    return 'DB INIT OK'