|
@@ -3,10 +3,12 @@ from flask import Flask, render_template, request, redirect
|
|
|
import os
|
|
import os
|
|
|
from pymongo import MongoClient
|
|
from pymongo import MongoClient
|
|
|
from bson.objectid import ObjectId
|
|
from bson.objectid import ObjectId
|
|
|
-
|
|
|
|
|
|
|
+#from json import dumps
|
|
|
|
|
+import json
|
|
|
|
|
|
|
|
def connect():
|
|
def connect():
|
|
|
- connection = MongoClient("10.0.1.10", 27017)
|
|
|
|
|
|
|
+ connection = MongoClient("10.0.1.10", 27017,connectTimeoutMS=10000)
|
|
|
|
|
+ #connection = MongoClient("127.0.0.1", 27017,connectTimeoutMS=10000)
|
|
|
handle = connection["dpTapeDB"]
|
|
handle = connection["dpTapeDB"]
|
|
|
handle.authenticate("gui", "GahN7chi")
|
|
handle.authenticate("gui", "GahN7chi")
|
|
|
return handle
|
|
return handle
|
|
@@ -29,9 +31,14 @@ def index_old():
|
|
|
|
|
|
|
|
@app.route("/loaddata", methods=['GET'])
|
|
@app.route("/loaddata", methods=['GET'])
|
|
|
def loaddata():
|
|
def loaddata():
|
|
|
- results = [x for x in handle.digilst.find()[0:5]]
|
|
|
|
|
|
|
+ results = [x for x in handle.digilst.find()[0:100]]
|
|
|
return render_template('data.json', results=results)
|
|
return render_template('data.json', results=results)
|
|
|
|
|
|
|
|
|
|
+@app.route("/load", methods=['GET'])
|
|
|
|
|
+def load():
|
|
|
|
|
+ results = [x for x in handle.digilst.find()[0:10]]
|
|
|
|
|
+ return json.dumps(results)
|
|
|
|
|
+
|
|
|
@app.route("/insert", methods=['GET'])
|
|
@app.route("/insert", methods=['GET'])
|
|
|
def insert():
|
|
def insert():
|
|
|
return render_template("insert.html")
|
|
return render_template("insert.html")
|
|
@@ -69,8 +76,7 @@ def write_insert():
|
|
|
"Category": category, "Duration": duration,
|
|
"Category": category, "Duration": duration,
|
|
|
"Location": location, "Format": format,
|
|
"Location": location, "Format": format,
|
|
|
"Note": note, "Status": status})
|
|
"Note": note, "Status": status})
|
|
|
- return redirect("/insert")
|
|
|
|
|
-
|
|
|
|
|
|
|
+ return render_template("ok.txt")
|
|
|
|
|
|
|
|
@app.route("/write_update", methods=['POST'])
|
|
@app.route("/write_update", methods=['POST'])
|
|
|
def write_update():
|
|
def write_update():
|
|
@@ -85,7 +91,7 @@ def write_update():
|
|
|
def write_delete():
|
|
def write_delete():
|
|
|
mongoid = ObjectId(request.form.get("mongoid"))
|
|
mongoid = ObjectId(request.form.get("mongoid"))
|
|
|
handle.digilst.remove({"_id": mongoid})
|
|
handle.digilst.remove({"_id": mongoid})
|
|
|
- return redirect("/delete")
|
|
|
|
|
|
|
+ return render_template("ok.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|