Skip to content

Instantly share code, notes, and snippets.

@Lebski
Last active September 10, 2022 20:07
Show Gist options
  • Save Lebski/e637d4d47887fb25843ae5042ae65c42 to your computer and use it in GitHub Desktop.
Save Lebski/e637d4d47887fb25843ae5042ae65c42 to your computer and use it in GitHub Desktop.
Flask basic file server - lets you serve your folder and nothing more
from flask import Flask, send_from_directory
app = Flask(__name__, static_url_path='', static_folder='files')
@app.route("/")
def index():
return send_from_directory("files", 'index.html')
if __name__ == "__main__":
app.run(debug=True)
@Lebski
Copy link
Author

Lebski commented Sep 10, 2022

A basic file server if you want to host a static website with a webserver in 10 lines of code

My folder name was "files" but feel free to change it to anything else in line 3 and 7.

Also the name of your index page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment