fixes #2
This commit is contained in:
parent
4766b6aeb1
commit
c704b5005c
10
app.py
10
app.py
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue