mirror of
https://github.com/alvierahman90/uploadr.git
synced 2025-01-12 02:04:20 +00:00
takes configuration from same file as gunicorn
This commit is contained in:
parent
4d392c3901
commit
2faf6233e0
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
uploads/*
|
||||
config.py
|
||||
|
@ -5,7 +5,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form action = "http://{{ ip }}:{{ port }}/upload" method = "POST"
|
||||
<form action = "/upload" method = "POST"
|
||||
enctype = "multipart/form-data">
|
||||
<div class="fileUpload btn">
|
||||
<span>Upload</span>
|
||||
|
@ -9,8 +9,8 @@
|
||||
<script>
|
||||
|
||||
file = document.getElementById('file_link');
|
||||
file.setAttribute('href','http://{{ ip }}:{{ port }}/download/{{ filename }}');
|
||||
file.innerHTML = 'http://{{ ip }}:{{ port }}/download/{{ filename }}';
|
||||
file.setAttribute('href','/download/{{ filename }}');
|
||||
file.innerHTML = '/download/{{ filename }}';
|
||||
|
||||
</script>
|
||||
</div>
|
||||
|
17
uploadr.py
17
uploadr.py
@ -1,15 +1,17 @@
|
||||
import time
|
||||
import flask
|
||||
import config
|
||||
from flask import Flask
|
||||
from flask import render_template
|
||||
from flask import request
|
||||
from flask import send_from_directory
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
port = 8080
|
||||
ip = "192.168.1.80"
|
||||
@app.route("/")
|
||||
@app.route("/hello/<name>")
|
||||
def hello(name=None):
|
||||
return render_template('hello.html',name=name)
|
||||
|
||||
@app.route('/upload', methods=['GET','POST'])
|
||||
def upload_file():
|
||||
@ -18,9 +20,14 @@ def upload_file():
|
||||
print(secure_filename(f.filename))
|
||||
filename = str(time.time()) + '.' + secure_filename(f.filename).split('.')[-1]
|
||||
f.save('./uploads/' + filename)
|
||||
return render_template('upload_success.html', filename = filename, port = port, ip = ip)
|
||||
return render_template('upload_success.html',
|
||||
filename = filename,
|
||||
port = config.port,
|
||||
)
|
||||
else:
|
||||
return render_template('upload.html', port = port, ip = ip)
|
||||
return render_template('upload.html',
|
||||
port = config.port,
|
||||
)
|
||||
|
||||
@app.route('/download/<filename>')
|
||||
def download(filename=None):
|
||||
|
Loading…
Reference in New Issue
Block a user