-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload zip to server #64
base: master
Are you sure you want to change the base?
Conversation
# TODO: Make sure this works | ||
with io.open(os.path.join(self._PATH, "users.json"), encoding="utf8") as f: | ||
self.__USER_DATA = {u["id"]: u for u in json.load(f)} | ||
def __init__(self, PATH=''): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: PATH
should be path
slackviewer/app.py
Outdated
flash("No selected file") | ||
return redirect(request.url) | ||
if file and allowed_file(file.filename): | ||
print("made it and it should extract the archive here") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there isn't great logging set up already, so print
is fine, but at the same time, I want to avoid having "made it" etc. logged :P
Perhaps "Extracting archive..." is sufficient.
file = request.files["archive_file"] | ||
# if user does not select file, browser also | ||
# submit a empty part without filename | ||
if file.filename == "": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not file.filename
works too
slackviewer/app.py
Outdated
@@ -7,14 +10,19 @@ | |||
static_folder="static" | |||
) | |||
|
|||
reader = Reader() | |||
|
|||
# these functions only fire when the route is navigated to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this comment?
@@ -72,9 +86,46 @@ def mpim_name(name): | |||
mpim_users=mpim_users) | |||
|
|||
|
|||
@app.route("/") | |||
ALLOWED_EXTENSIONS = set(["zip"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constants like this should be at the top of the file
def allowed_file(filename): | ||
return "." in filename and \ | ||
filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two newlines between all module-level functions
|
||
@app.route("/", methods=["GET", "POST"]) | ||
def upload(): | ||
print('upload') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the request I have general for these print statements is, can you just clean them up a bit?
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: #f5f5f5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mismatched indentation in this file bothers me, please use an auto formatter of some kind in your editor to clean it up. Thanks. :)
@@ -0,0 +1,70 @@ | |||
@import url('https://fonts.googleapis.com/css?family=Lato:400,900'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the indentation in this file
Hey @hfaran just mostly wanted to show you what I worked on. I had to get this out this week for my work. I can fix all of this stuff. |
Well, as long as:
implementation looks fine to me. 👍 😄 |
… to be the absolute path
Change Reader object to store all of the data instead of returning it from the compile functions
Change app routes to use reader values
Add upload view to upload a zip file
Some tech debt: