Commit 8fd20f87 authored by Nicholas J Anderson's avatar Nicholas J Anderson
Browse files

Added index page

parent 26039fcf
from flask import Flask, jsonify
from flask import Flask, jsonify, render_template
from peoplefinder import call_standard
app = Flask(__name__)
@app.route('/')
def base_api():
return 'Peoplefinder Api'
return render_template('index.html')
@app.route('/all/<search>')
def search_all(search):
......
{% raw %}
<!DOCTYPE html>
<!--[if IE 9]<html class="lt-ie10" lang="en"><![endif]-->
<html class="no-js"lang="en" ng-app="peoplefinderApp">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SRCT's PeopleFinder API</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/css/normalize.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/css/foundation.min.css">
<style>
.srct-logo {
width:19px;
height:19px;
margin-right:5px;
}
.contain-to-grid, .top-bar {
background-color:#063;
}
.top-bar .name h1 {
/* display:inline-block; */
}
.top-bar .name h1 a {
font-weight: bold;
width:100%;
}
dt {
float: left;
clear: left;
margin: 0;
padding: 0 .5em 0 0;
font-weight:normal !important;
}
dt:after {
content:":";
}
dd {
margin: 0;
padding: 0;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/js/vendor/modernizr.js"></script>
</head>
<body ng-controller="QueryCtrl">
<div class="contain-to-grid">
<nav class="top-bar" data-topbar role="navigation">
<ul class="title-area">
<li class="name">
<h1><a href="#"><img src="http://srct.gmu.edu/static/img/SRCT_square_white.png" class="srct-logo">PeopleFinder API</a></h1>
</li>
</ul>
</nav>
</div>
<div class="row">
<div class="large-12 columns">
<h1>Query Builder</h1>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<div class="alert-box alert" ng-show="error && !dismissed">
{{error}}
<a href="#" ng-click="dismiss()" class="close">&times;</a>
</div>
</div>
</div>
<div class="row">
<form ng-submit="doQuery();">
<div class="large-6 medium-12 columns">
<label>Query Group
<select ng-model="group" ng-change="updateUrl();">
<option value="all">Students and Faculty</option>
<option value="students">Students Only</option>
<option value="faculty">Faculty Only</option>
</select>
</label>
</div>
<div class="large-6 medium-12 columns">
<label>Query String
<input type="text" placeholder="Query String" ng-change="updateUrl();" ng-required ng-model="generalStr">
</label>
</div>
<input type="submit" style="display:none">
</form>
</div>
<div class="row">
<div class="large-12 columns">
<div class="row collapse">
<div class="small-10 columns">
<input type="text" ng-model="query" disabled>
</div>
<div class="small-2 columns">
<a href="#" class="button postfix" ng-click="doQuery();">Go!</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="large-12 columns" ng-repeat="result in results">
<dl>
<h4>{{result.name}}</h4>
<dt ng-show="{{!!result.email}}">Email</dt>
<dd ng-show="{{!!result.email}}"><a href="mailto:{{result.email}}">{{result.email}}</a></dd>
<dt ng-show="{{!!result.address}}">Address</dt>
<dd ng-show="{{!!result.address}}">{{result.address}}</dd>
<dt ng-show="{{!!result.phone}}">Phone</dt>
<dd ng-show="{{!!result.phone}}">{{result.phone}}</dd>
<dt ng-show="{{!!result.fax}}">Fax</dt>
<dd ng-show="{{!!result.fax}}">{{result.fax}}</dd>
<dt ng-show="{{!!result.major}}">Major</dt>
<dd ng-show="{{!!result.major}}">{{result.major}}</dd>
</dl>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script>
var peoplefinderApp = angular.module('peoplefinderApp', []);
var baseURL = window.location.protocol+"//"+window.location.host;
peoplefinderApp.controller('QueryCtrl', function($scope, $http) {
$scope.results = [];
$scope.group = "all";
$scope.generalStr = "";
$scope.doQuery = function() {
$http.get(baseURL + "/" + $scope.group + "/" + $scope.generalStr).success(function(data) {
console.log(data);
$scope.results = data.results;
}).error(function(data, status, headers, config) {
$scope.error = "Oops! Looks like that query didn't work!";
$scope.dismissed = false;
})
}
$scope.updateUrl = function() {
$scope.query = baseURL + "/" + $scope.group + "/" + $scope.generalStr;
}
$scope.updateUrl()
$scope.dismiss = function() {
$scope.dismissed = true;
}
});
</script>
</body>
</html>
{% endraw %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment