-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·32 lines (23 loc) · 1022 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask, render_template, request, send_file
import textTo3D
import os
app = Flask(__name__)
UPLOAD_FOLDER = os.path.join(os.getcwd(), 'downloads')
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
@app.route('/', methods=['GET', 'POST'])
def index():
modelID = None
modelJSON = None
if request.method == 'POST':
if 'promptForm' in request.form:
prompt = request.form.get('prompt')
style = request.form.get('style')
modelID = textTo3D.getModelID(prompt,style)
elif 'ModelForm' in request.form:
modelId = request.form.get('modelId')
modelJSON = textTo3D.downloadModelInObjFormat(modelId, UPLOAD_FOLDER)
file_path = os.path.join(UPLOAD_FOLDER, 'result.obj')
return send_file(file_path, as_attachment=True, download_name='model.obj')
return render_template('index.html', modelID=modelID, modelJSON=modelJSON)
if __name__ == '__main__':
app.run(host='127.0.0.1', port=8080, debug=True)