瀏覽代碼

initial frontend

David 10 年之前
父節點
當前提交
1521ab100e
共有 5 個文件被更改,包括 434 次插入0 次删除
  1. 33 0
      front/index.html
  2. 二進制
      front/js/.app.js.swp
  3. 314 0
      front/js/angular.min.js
  4. 47 0
      front/js/app.js
  5. 40 0
      web.py

+ 33 - 0
front/index.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html ng-app="app">
+	<head>
+		<!-- Latest compiled and minified CSS -->
+		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
+
+		<!-- Optional theme -->
+		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
+
+		<!-- Latest compiled and minified JavaScript -->
+		<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
+
+		<script src="js/angular.min.js"></script>
+		<script src="js/app.js"></script>
+	</head>
+<body>
+	<div ng-controller="main">
+		<div class="row">
+			<div class="col-sm-2 col-md-2 col-lg-2 col-xl-2" style="min-height:100%;background-color:red">
+			</div>
+			<div class="col-sm-4 col-md-4 col-lg-4 col-xl-4" style="min-height:100%;background-color:blue">
+				<div class="row" ng-repeat="n in news">
+					news:
+				</div>
+			</div>
+			<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6" style="min-height:100%;background-color:green">
+
+			</div>
+		</div>
+	</div>
+</body>
+</html>
+

二進制
front/js/.app.js.swp


File diff suppressed because it is too large
+ 314 - 0
front/js/angular.min.js


+ 47 - 0
front/js/app.js

@@ -0,0 +1,47 @@
+app=angular.module('app', []);
+
+app.controller('main', function($scope,$http) {
+	$scope.news=[];
+
+	$scope.getNews = function() {
+		$http.get("/news/").then(
+		function(data) {
+			/*
+			data.data=data.data.map(function(el) {
+				if (el.STATUS!="DISCONNECTED")
+					el.STATUS=el.STATUS+" "+el.ELAPSED;
+				return el;
+			});
+			*/
+			$scope.news=data.data;
+		},
+		function(data){
+			console.log("error");
+			console.log(data);
+		});
+	}
+	$scope.getNews();
+	/*
+
+	$scope.download = function(book) {
+		$http.post("/test/?adasasd",{"type":"BOOK","book":book}).then(
+		function(data) {
+			$scope.getList();
+		},
+		function(data){
+			console.log("error");
+			console.log(data);
+		});
+	};
+	$scope.searchBook = function(book,extension){
+		$http.post("/test/?ewqewqewq", {"type":"search","book":book,"extension":extension}).then(
+		function(data) {
+			console.log("success");
+			$scope.getList();
+		},
+		function(data){
+			console.log("err");
+		});
+	};
+	*/
+});

+ 40 - 0
web.py

@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+from flask import Flask,abort,jsonify
+
+app = Flask(__name__)
+
+@app.route('/')
+def index():
+    return "Hello, World!"
+
+@app.route('/sources', methods=['GET'])
+def get_sources():
+    sources=[]
+    return jsonify({'sources': sources})
+
+
+@app.route('/sources/<int:source_id>', methods=['GET'])
+def get_source(source_id):
+    sources=[]
+    source = [s for s in sources if s['id'] == source_id]
+    if len(source) == 0:
+        abort(401)
+    return jsonify({'source': source[0]})
+
+
+@app.route('/add_source', methods=['POST'])
+def create_task():
+    if not request.json or not 'title' in request.json:
+        abort(400)
+    task = {
+        'id': tasks[-1]['id'] + 1,
+        'title': request.json['title'],
+        'description': request.json.get('description', ""),
+        'done': False
+    }
+    tasks.append(task)
+    return jsonify({'task': task}), 201
+
+if __name__ == '__main__':
+    app.run(debug=True)