2022-10-09 11:48:31 -04:00
|
|
|
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-09 11:48:31 -04:00
|
|
|
|
2022-10-10 07:04:14 -04:00
|
|
|
@app.route("/complete",methods=['GET'])
|
|
|
|
def complete():
|
2022-10-09 11:48:31 -04:00
|
|
|
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)
|
2022-10-09 11:48:31 -04:00
|
|
|
return json.dumps(data)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app.run()
|