|
|
@@ -13,6 +13,7 @@ db = SQLAlchemy()
|
|
|
app = flask.Flask(__name__)
|
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:m9Eb5OflQb@mysql.mysql.svc.cluster.local/gopy'
|
|
|
db.init_app(app)
|
|
|
+list_fqdn = "https://go.dezendorf.net/list"
|
|
|
|
|
|
migrate = Migrate(app, db)
|
|
|
|
|
|
@@ -57,9 +58,9 @@ def redirect_to_link(name):
|
|
|
try:
|
|
|
link = Link.query.filter_by(name=name).first()
|
|
|
except e:
|
|
|
- return redirect("/list", code=302)
|
|
|
+ return redirect(list_fqdn)
|
|
|
if link is None:
|
|
|
- return redirect("/list", code=302)
|
|
|
+ return redirect(list_fqdn)
|
|
|
try:
|
|
|
link.hit_count += 1
|
|
|
except TypeError:
|
|
|
@@ -79,7 +80,7 @@ def add_link():
|
|
|
link = Link(name=request.form['link_name'], target=request.form['target'], hit_count=0, owner_name="unknown")
|
|
|
db.session.add(link)
|
|
|
db.session.commit()
|
|
|
- return redirect("/list", code=302)
|
|
|
+ return redirect(list_fqdn)
|
|
|
|
|
|
|
|
|
@app.route('/<string:link_name>/add', strict_slashes=False)
|
|
|
@@ -94,7 +95,7 @@ def edit_link(link_name):
|
|
|
print("Setting link target to {}".format(request.form['target']))
|
|
|
link.target = request.form['target']
|
|
|
db.session.commit()
|
|
|
- return redirect("/list", code=302)
|
|
|
+ return redirect(list_fqdn)
|
|
|
|
|
|
|
|
|
@app.route('/<string:link_name>/edit', strict_slashes=False)
|
|
|
@@ -108,7 +109,7 @@ def delete_link(link_id):
|
|
|
link = Link.query.filter_by(id=link_id).first()
|
|
|
db.session.delete(link)
|
|
|
db.session.commit()
|
|
|
- return redirect(url_for('list_links'))
|
|
|
+ return redirect(list_fqdn)
|
|
|
|
|
|
|
|
|
@app.route('/<int:link_id>/delete', strict_slashes=False)
|
|
|
@@ -125,12 +126,8 @@ def list_links():
|
|
|
|
|
|
@app.route('/')
|
|
|
def landing_page():
|
|
|
- return redirect("/list", code=302)
|
|
|
+ return redirect(list_fqdn)
|
|
|
|
|
|
-#@app.route('/links/<int:id>', methods=['GET'])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
- parser = argparse.ArgumentParser()
|
|
|
- parser.add_argument("admin", help="Make admin functions available", action="store_true")
|
|
|
- parser.parse_args()
|
|
|
app.run(host='0.0.0.0')
|