interverse/server/interverse-proxy.py

32 lines
802 B
Python
Raw Normal View History

from flask import Flask,request,redirect
import json,requests,time
import simple_cache
cache = simple_cache.Cache()
2022-10-10 07:04:14 -04:00
print("Cache intitialized.")
app = Flask('interverse-proxy')
@app.route('/')
def index():
return redirect("https://codeberg.org/gabe/Interverse",307)
@app.route("/initial", methods=['GET'])
def initial():
url = request.args.get('url')
if url == None:
return redirect("https://codeberg.org/gabe/Interverse",307)
data = cache.load_data(url)
return json.dumps(data)
2022-10-10 07:04:14 -04:00
@app.route("/complete",methods=['GET'])
def complete():
url = request.args.get('url')
if url == None:
return redirect("https://codeberg.org/gabe/Interverse",307)
2022-10-10 04:22:04 -04:00
data = cache.get_interverse_data(url)
return json.dumps(data)
if __name__ == '__main__':
app.run()