Fixed typo
This commit is contained in:
parent
0401acd31b
commit
416d7fdd6d
|
@ -30,6 +30,10 @@ class handler(asyncTornado.asyncRequestHandler):
|
||||||
if False in args_filter:
|
if False in args_filter:
|
||||||
raise Exception("Missing required arguments")
|
raise Exception("Missing required arguments")
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(args_filter)
|
||||||
|
print()
|
||||||
|
|
||||||
method = args_filter[0]
|
method = args_filter[0]
|
||||||
method_value = self.request.arguments[method]
|
method_value = self.request.arguments[method]
|
||||||
|
|
||||||
|
@ -44,13 +48,15 @@ class handler(asyncTornado.asyncRequestHandler):
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
data = cur.fetchone()
|
data = cur.fetchone()
|
||||||
|
|
||||||
|
cur.close()
|
||||||
|
|
||||||
status_code = 200
|
status_code = 200
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
status_code = 400
|
status_code = 400
|
||||||
data["status"] = status_code
|
data["status"] = status_code
|
||||||
data["message"] = e
|
data["message"] = e
|
||||||
finally:
|
finally:
|
||||||
cur.close()
|
print(data)
|
||||||
|
|
||||||
self.write( json.dumps(data) )
|
self.write( json.dumps(data) )
|
||||||
self.set_header("Content-Type", "application/json")
|
self.set_header("Content-Type", "application/json")
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
import json
|
|
||||||
#import MySQLdb
|
|
||||||
#import MySQLdb.cursors
|
|
||||||
from flask import Flask, make_response, request, render_template, jsonify
|
|
||||||
from objects import glob
|
|
||||||
|
|
||||||
import api
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
with open("config.json", "r") as f:
|
|
||||||
config = json.load(f)
|
|
||||||
|
|
||||||
# Setup sql
|
|
||||||
#glob.sql = MySQLdb.connect(**config["sql"], cursorclass = MySQLdb.cursors.DictCursor)
|
|
||||||
|
|
||||||
@app.route("/")
|
|
||||||
@app.route("/home")
|
|
||||||
def home_index():
|
|
||||||
return render_template("index.html")
|
|
||||||
|
|
||||||
@app.route("/download")
|
|
||||||
def download_index():
|
|
||||||
return render_template("download.html")
|
|
||||||
|
|
||||||
@app.route("/api")
|
|
||||||
def api_index():
|
|
||||||
return render_template("api.html")
|
|
||||||
|
|
||||||
@app.route("/api/<ver>/<func>")
|
|
||||||
def api_call(ver, func):
|
|
||||||
if ver not in api.versions or func not in api.versions[ver].handlers:
|
|
||||||
return jsonify(api.missing.handle(request))
|
|
||||||
data = api.versions[ver].handlers[func].handle(request)
|
|
||||||
return jsonify(data)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app.run(**config["web"])
|
|
19
import_database.py
Normal file
19
import_database.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
if __name__ != "__main__":
|
||||||
|
print("This is not a module")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print("Missing database import file")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
sql = sqlite3.connect("wayback.db")
|
||||||
|
cur = sql.cursor()
|
||||||
|
|
||||||
|
with open(sys.argv[1], "r") as f:
|
||||||
|
cur.executescript( f.read() )
|
||||||
|
|
||||||
|
cur.close()
|
||||||
|
sql.close()
|
2
main.py
2
main.py
|
@ -40,7 +40,7 @@ def make_app():
|
||||||
api = api.rstrip(".py")
|
api = api.rstrip(".py")
|
||||||
routes.append(
|
routes.append(
|
||||||
(
|
(
|
||||||
r"/%s/%s" % (dir, api), __import__("%s.%s" % (dir.replace("/", "."), api), fromlist=[""])
|
r"/%s/%s" % (dir, api), __import__("%s.%s" % (dir.replace("/", "."), api), fromlist=[""]).handler
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
routes += map_routes("%s/%s" % (dir, api))
|
routes += map_routes("%s/%s" % (dir, api))
|
||||||
|
|
|
@ -84,7 +84,7 @@ def check_arguments(arguments, arguments_filter):
|
||||||
def arg_filter_and(arguments, filter, can_false = False):
|
def arg_filter_and(arguments, filter, can_false = False):
|
||||||
arg_filter = []
|
arg_filter = []
|
||||||
for i in filter:
|
for i in filter:
|
||||||
if i in filter:
|
if i in arguments:
|
||||||
arg_filter.append(i)
|
arg_filter.append(i)
|
||||||
if can_false:
|
if can_false:
|
||||||
return arg_filter if len(arg_filter) else False
|
return arg_filter if len(arg_filter) else False
|
||||||
|
@ -105,6 +105,6 @@ def arg_filter_only_one(arguments, required):
|
||||||
|
|
||||||
def arg_filter_first(arguments, filter, optional = True):
|
def arg_filter_first(arguments, filter, optional = True):
|
||||||
for i in filter:
|
for i in filter:
|
||||||
if i in filter:
|
if i in arguments:
|
||||||
return i
|
return i
|
||||||
return optional
|
return optional
|
||||||
|
|
Loading…
Reference in New Issue
Block a user