generated from Eddie/Backend-Boilerplate
Eddie
2 years ago
5 changed files with 13 additions and 17 deletions
@ -1,20 +1,22 @@ |
|||||||
import os |
import os |
||||||
from flask import Flask, render_template |
from flask import Flask, render_template, send_file |
||||||
from planets import createRandomPlanet |
from planets import createRandomPlanet |
||||||
|
|
||||||
app = Flask(__name__) |
app = Flask(__name__) |
||||||
|
|
||||||
|
|
||||||
IMG_FOLDER = os.path.join('static', 'IMG') |
IMG_FOLDER = os.path.join('static', 'IMG') |
||||||
|
|
||||||
app.config['UPLOAD_FOLDER'] = IMG_FOLDER |
app.config['UPLOAD_FOLDER'] = IMG_FOLDER |
||||||
|
|
||||||
|
@app.route('/') |
||||||
|
def index(): |
||||||
|
planet = os.path.join(app.config['UPLOAD_FOLDER'], 'planet.png') |
||||||
|
return render_template('index.html', planet=planet) |
||||||
|
|
||||||
@app.route('/<seed>') |
@app.route('/<seed>') |
||||||
def hello(seed): |
def hello(seed): |
||||||
print(seed) |
|
||||||
createRandomPlanet(seed) |
createRandomPlanet(seed) |
||||||
planet = os.path.join(app.config['UPLOAD_FOLDER'], 'planet.png') |
planet = os.path.join(app.config['UPLOAD_FOLDER'], 'planet.png') |
||||||
return render_template('hello.html', planet=planet) |
return send_file(planet) |
||||||
|
|
||||||
|
|
||||||
if __name__=='__main__': |
if __name__=='__main__': |
||||||
app.run(debug=True, host='0.0.0.0') |
app.run(debug=True, host='0.0.0.0') |
Before Width: | Height: | Size: 434 KiB |
Before Width: | Height: | Size: 378 KiB After Width: | Height: | Size: 443 KiB |
Loading…
Reference in new issue