from flask import Flask, render_template, request, redirect, url_for
from werkzeug.utils import secure_filename
import datetime
import os

def timestamp():
    return datetime.datetime.now().strftime('%Y%m%d%H%M%S')

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = '/uploads'


@app.route('/', methods=['GET'])
def index():
    return '''
    <!doctype html>
    <title>Hi</title>
    Hi
    '''

#curl -F file=@"/tmp/test.txt" https://[site]/[app_path]/ul
@app.route('/ul', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            return redirect(request.url)
        if file:
            filename = '{}_{}.data'.format(timestamp(), secure_filename(file.filename))
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            return redirect(url_for('upload_file'))
    return '''
    <!doctype html>
    <title>Hi</title>
    Hi
    '''

from flask import Flask, render_template, request, redirect, url_for
from werkzeug.utils import secure_filename
import datetime
import os

def timestamp():
    return datetime.datetime.now().strftime('%Y%m%d%H%M%S')

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = '/uploads'


@app.route('/', methods=['GET'])
def index():
    return '''
    <!doctype html>
    <title>Hi</title>
    Hi
    '''

#curl -F file=@"/tmp/test.txt" https://[site]/[app_path]/ul
@app.route('/ul', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            return redirect(request.url)
        if file:
            filename = '{}_{}.data'.format(timestamp(), secure_filename(file.filename))
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            return redirect(url_for('upload_file'))
    return '''
    <!doctype html>
    <title>Upload</title>
    <form enctype="multipart/form-data" action="/ul" method="POST">
    <input type="file" id="file" name="file">
    <input type="submit">
    </form>
    '''


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000)

Add simple form to flask upload server
Add simple form to flask upload server

  from flask import Flask, render_template, request, redirect, url_for
  from werkzeug.utils import secure_filename
  import datetime
  import os
  
  def timestamp():
      return datetime.datetime.now().strftime('%Y%m%d%H%M%S')
  
  app = Flask(__name__)
  app.config['UPLOAD_FOLDER'] = '/uploads'
  
  
  @app.route('/', methods=['GET'])
  def index():
      return '''
      <!doctype html>
      <title>Hi</title>
      Hi
      '''
  
  #curl -F file=@"/tmp/test.txt" https://[site]/[app_path]/ul
  @app.route('/ul', methods=['GET', 'POST'])
  def upload_file():
      if request.method == 'POST':
          if 'file' not in request.files:
              return redirect(request.url)
          file = request.files['file']
          if file.filename == '':
              return redirect(request.url)
          if file:
              filename = '{}_{}.data'.format(timestamp(), secure_filename(file.filename))
              file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
              return redirect(url_for('upload_file'))
      return '''
      <!doctype html>
-     <title>Hi</title>
+     <title>Upload</title>
-     Hi
+     <form enctype="multipart/form-data" action="/ul" method="POST">
+     <input type="file" id="file" name="file">
+     <input type="submit">
+     </form>
      '''
  
+ 
+ if __name__ == '__main__':
+     app.run(host='0.0.0.0', port=8000)
+ 
Add simple form to flask upload server
## Code Before:
from flask import Flask, render_template, request, redirect, url_for
from werkzeug.utils import secure_filename
import datetime
import os

def timestamp():
    return datetime.datetime.now().strftime('%Y%m%d%H%M%S')

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = '/uploads'


@app.route('/', methods=['GET'])
def index():
    return '''
    <!doctype html>
    <title>Hi</title>
    Hi
    '''

#curl -F file=@"/tmp/test.txt" https://[site]/[app_path]/ul
@app.route('/ul', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            return redirect(request.url)
        if file:
            filename = '{}_{}.data'.format(timestamp(), secure_filename(file.filename))
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            return redirect(url_for('upload_file'))
    return '''
    <!doctype html>
    <title>Hi</title>
    Hi
    '''

## Instruction:
Add simple form to flask upload server
## Code After:
from flask import Flask, render_template, request, redirect, url_for
from werkzeug.utils import secure_filename
import datetime
import os

def timestamp():
    return datetime.datetime.now().strftime('%Y%m%d%H%M%S')

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = '/uploads'


@app.route('/', methods=['GET'])
def index():
    return '''
    <!doctype html>
    <title>Hi</title>
    Hi
    '''

#curl -F file=@"/tmp/test.txt" https://[site]/[app_path]/ul
@app.route('/ul', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            return redirect(request.url)
        if file:
            filename = '{}_{}.data'.format(timestamp(), secure_filename(file.filename))
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            return redirect(url_for('upload_file'))
    return '''
    <!doctype html>
    <title>Upload</title>
    <form enctype="multipart/form-data" action="/ul" method="POST">
    <input type="file" id="file" name="file">
    <input type="submit">
    </form>
    '''


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000)
