added app
This commit is contained in:
parent
9d7bc391a7
commit
21b82eb274
File diff suppressed because one or more lines are too long
27
app.py
Normal file
27
app.py
Normal file
@ -0,0 +1,27 @@
|
||||
from flask import Flask, send_file, render_template, request
|
||||
import os
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/generate', methods=['POST'])
|
||||
def generate():
|
||||
# Call your Python script or function here
|
||||
output_file = generate_file()
|
||||
|
||||
# Provide the file for download
|
||||
return send_file(output_file, as_attachment=True)
|
||||
|
||||
def generate_file():
|
||||
# This is where you generate your file
|
||||
# For demonstration, we will create a simple text file
|
||||
output_path = 'output.txt'
|
||||
with open(output_path, 'w') as f:
|
||||
f.write('Hello, this is the generated file.')
|
||||
return output_path
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
27
templates/index.html
Normal file
27
templates/index.html
Normal file
@ -0,0 +1,27 @@
|
||||
from flask import Flask, send_file, render_template, request
|
||||
import os
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/generate', methods=['POST'])
|
||||
def generate():
|
||||
# Call your Python script or function here
|
||||
output_file = generate_file()
|
||||
|
||||
# Provide the file for download
|
||||
return send_file(output_file, as_attachment=True)
|
||||
|
||||
def generate_file():
|
||||
# This is where you generate your file
|
||||
# For demonstration, we will create a simple text file
|
||||
output_path = 'output.txt'
|
||||
with open(output_path, 'w') as f:
|
||||
f.write('Hello, this is the generated file.')
|
||||
return output_path
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
Loading…
Reference in New Issue
Block a user