Ejemplo n.º 1
0
def init_server(**kwargs):
	server = Server(**kwargs)

	# API pages
	server.register('/game', game)
	server.register('/player', player, post=player)
	server.register('/murder', murder, post=murder_submit)
	server.register('/achievement_progress', achievement_progress)
	server.register('/login', login_page, post=login)

	# HTML pages
	game_id = '/([0-9a-zA-Z-]+)'
	player_id = '([a-zA-Z+-]+)'
	server.register('/admin/?', admin)
	server.register('{}/admin/?'.format(game_id), admin)
	server.register('{}/admin/lodge/?'.format(game_id), lodge)
	server.register('{}/profiles/?'.format(game_id), profiles)
	server.register('{}/profiles/{}/?'.format(game_id, player_id), profile)
	server.register('{}/map/?'.format(game_id), murder_map)
	server.register('{}/murders/?'.format(game_id), murder_list)
	server.register('{}/stats/?'.format(game_id), stats)
	server.register('{}/achievements/?'.format(game_id), achievements)
	server.register('{}?/?'.format(game_id), home)	

	return server
Ejemplo n.º 2
0
    if password != confpass:
        request.redirect('/profilecreation/')

    for f in profile_fields:
        field.append(request.get_field(f))

    user = create_seeker('./database/seekers_personal.db', field)
    request.set_secure_cookie('user_id', str(user.id))
    request.redirect('/')


def pagenotfound_handler(request):
    render(request, 'pagenotfound.html', {"login": check_logged_in(request)})


server = Server()  # Create a server object
server.register(r'/', index_handler)

try:
    from chatbot.ai import ChatBotWebSockets
    # def chat_handler (request):
    #     return render(request, 'chatbot/chat.html', {"login": check_logged_in(request)})
    server.register(r'/ws/', ChatBotWebSockets)
    # server.register(r'/chat/', chat_handler)
except ImportError:
    pass

server.register(r'/profile/', profilelistpage_handler)
server.register(r'/searchresult/(.*)/(.+)/', searchresult_handler)
server.register(r'/position/', positionlist_handler)
server.register(
Ejemplo n.º 3
0
    request.write(templater.render("templates/charity_list.html", context))


def default_handler(request, method):
    request.write("Invaild url silly!")
    """Redirects all invalid urls to this"""


"""def next_charity_handler(request, )"""
""" Sends user to new page and sends info to data base"""

# \d+ is any number
# .+ = any letter but preferably a name!!

args = parser.parse_args()
server = Server(port=args.port)
server.register(r"/?", home_page_handler)
server.register(r"/charity_profile/(\d+)/?", charity_profile_handler)
server.register(r"/create_charity_profile/?", create_charity_profile_handler)
server.register(r"/post_create_charity_profile/?",
                post_create_charity_profile_handler)
server.register(r"/swipe/(\d+)/(left|right)/?", swipe_screen_handler)
server.register(r"/feed/?", feed_handler)
server.register(r"/about/?", about_handler)
server.register(r"/user_profile/(\d+)/(.+)/?", user_profile_handler)
server.register(r"/create_user_profile/?", create_user_profile_handler)
server.register(r"/post_create_user_profile/?",
                post_create_user_profile_handler)
server.register(r"/user/?", user_handler)
server.register(r"/charity_list/?", charity_list_handler)
server.set_default_handler(default_handler)
Ejemplo n.º 4
0
                'signed_in': authenticate_cookie(request),
                'username': get_username(request)
            }))


def not_found_handler(request):
    request.write(
        render(
            '404.html', {
                'users': db.User.find_all(),
                'signed_in': authenticate_cookie(request),
                'username': get_username(request)
            }))


server = Server()
server.register(r'/', index_handler)
server.register(r'/view/(\d+)/?', view.view_question_handler)
server.register(r'/signup', user.signup_handler, post=user.signup_handler_post)
server.register(r'/ask', ask.ask_handler, post=ask.ask_handler_post)
server.register(r'/signin', user.signin_handler, post=user.signin_handler_post)
server.register(r'/post_comment/(\d+)/?',
                view.comment_handler_post,
                post=view.comment_handler_post)
server.register(r'/logout', user.signout_handler)
server.register(r'/list_users', handle_list_users)
server.register(r'/profile/(.+)',
                profile.view_handler,
                post=profile.view_handler_post)
server.register(r'/profile/edit/(.+)',
                profile.edit_handler,
Ejemplo n.º 5
0
#!/usr/bin/env python3
import os

from tornado.ncss import Server


def index(response):
    response.write('Hello World!')


port = os.getenv('PORT')
if port:
  server = Server(port=int(port))
else:
  server = Server()

server.register('/', index)
server.run()
Ejemplo n.º 6
0
def logout_handler(request):
    if not is_authorised(request):
        request.redirect(r'/')
        return

    request.clear_cookie('user_id')
    request.redirect(r'/')

def error404_handler(request):
    request.write(render_template('error404.html', {'title' : "Error 404" }))

# GET /list/create - Call create screen
# POST /list/create - Post list to server and redirects to created list.
# GET /list/<listID> - Shows list referring to listID or says list not found.
# GET / - If not logged in, Shows decription and if you are, shows feed.

server = Server(hostname = '0.0.0.0')
server.register(r'/', index_handler)
server.register(r'/login', login_handler)
server.register(r'/list/(\d+)/create', list_creation_handler)
server.register(r'/list/(\d+)', list_display_handler)
server.register(r'/list/(\d+)/edit', list_edit_handler)
server.register(r'/logout', logout_handler)
server.register(r'/user/create', signup_handler)
server.register(r'/user/edit', profile_edit_handler)
server.register(r'/timeline/([0-9]+)', timeline_handler)
server.register(r'/.+', error404_handler)

server.run()