Bernkastel wrote:
Why do you advertise this thread in a RPG section
Because the fact that Discord throws highlights current channels is the same way they highlight unread channels, which is fucking autistic.
Yoko wrote:
how do I make an img hosting website ;/
idk how that would be coded ;/
Not sure if you're joking or not. Not that it's a stupid question, but the emojis make me uncertain.
Here
http://Hexpresso.net - made it when I got really bored and wanted a place for me to throw shit up.
The base concept of an image host is fairly easy.
Take files with image extensions
Save them all to a directory with random names(if you so choose)
Output uploaded image urls to users when finished
Serve said images when url is requested
That's conveyed fairly simply in the following code using Python's Flask.
from flask import Flask, render_template, request, send_from_directory
#Configuring Flask to run properly with root privs, and setting static dir
#to serve static files(uploads)
app = Flask(__name__, static_url_path='/static')
#Allowed extensions.
ALLOWED_FILES = [
'jpg', 'png', 'gif',
'c', 'cpp', 'jpeg',
'txt', 'java', 'pdf'
]
@app.route('/', methods=['GET', 'POST'])
def index():
return render_template('index.html')
@app.route('/upload', methods=['POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
f_ext = f.filename.split('.')[1]
if f_ext in ALLOWED_FILES:
f.save('static/uploads/' + f.filename)
return render_template('index.html', file_name=f.filename)
else:
return render_template('index.html', rude_dood=True)
#So idiots can actually be served files.
@app.route('/<filename>', methods=['GET'])
def serve_static(filename):
print(filename)
return send_from_directory('static/uploads/', filename)
if __name__ == '__main__':
app.debug = True
app.run()