Initial super-trivial server

Bradlee Speice 2017-03-19 13:46:50 -04:00
parent 8ede6abb9b
commit 0c92b0b9cd
4 changed files with 64 additions and 1 deletions

View File

@ -6,6 +6,7 @@ def intersecting_games(*args):
api = steam.SteamAPI()
games_list = [api.get_games(steamid) for steamid in args]
ids_mutual = reduce(lambda l, r: set(l.keys()).intersection(r.keys()), games_list)
game_ids = [g.keys() for g in games_list]
ids_mutual = reduce(lambda l, r: set(l).intersection(r), game_ids)
return {game_id: games_list[0][game_id] for game_id in ids_mutual}

playwithfriends/ Normal file
View File

@ -0,0 +1,34 @@
from bottle import route, run, request
from playwithfriends.templates import render_template
from playwithfriends.steam import SteamAPI
from playwithfriends.intersections import intersecting_games
def index():
return render_template('index.html')
def get_friends():
api = SteamAPI()
steam64_id = api.get_steam64_from_profile(request.params['profile_url'])
friends_ids = api.get_friends_ids(steam64_id)
return api.get_player_names(friends_ids)
def get_games():
player_ids = request.params['player_ids'].split(',')
inter_games = intersecting_games(*player_ids)
return inter_games
def main():
run(host='localhost', port=8000)
if __name__ == '__main__':

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<h1>The Server is Working!</h1>

View File

@ -0,0 +1,15 @@
from os import path
from bottle import SimpleTemplate
def render_template(template_name, params=None):
if params is None:
params = {}
package_dir = path.abspath(path.dirname(__file__))
static_dir = path.join(package_dir, 'static')
with open(path.join(static_dir, template_name), 'r') as handle:
template = SimpleTemplate(
return template.render(**params)