This commit is contained in:
Matthias Seidl 2020-11-24 17:50:57 +01:00
parent 4766b6aeb1
commit c704b5005c
2 changed files with 16 additions and 1 deletions

10
app.py
View File

@ -144,6 +144,16 @@ def upload():
return 'OK'
@app.route('/delete', methods=['POST'])
def delete():
file_sha = request.form.get('sha')
path = request.form.get('path')
payload = {"sha": file_sha, "message": "WEB API delete file"}
resp = oauth.gitea.request('DELETE', urllib.parse.quote('{}/contents/{}'.format(app.config.get('REPO_URL'), path)), data=json.dumps(payload), headers={'Content-type': 'application/json'})
return redirect('/')
if __name__ == "__main__":
gitea = oauth.create_client('gitea')
app.run(debug=True)

View File

@ -5,7 +5,12 @@
<ul>
{% for file in files %}
{% if file.type == 'file' %}
<li><a href="/edit?path={{ file.path }}">{{ file.name }}</a></li>
<form method='POST' action='/delete'>
<li><a href="/edit?path={{ file.path }}">{{ file.name }}</a><input type='submit' value="Delete - no questions asked!"></li>
<input type='hidden' id='sha' name='sha' value='{{ file.sha }}'>
<input type='hidden' id='path' name='path' value='{{ file.path }}'>
</form>
{% else %}
<li><a href="/?path={{ file.path }}">{{ file.name }}/</a></li>
{% endif %}