belyalov / tinyweb

Simple and lightweight HTTP async server for micropython
MIT License
239 stars 40 forks source link

Remove dot prefix from mime_types data structure #1

Closed 0x7162 closed 6 years ago

0x7162 commented 6 years ago

Minor: I suppose period prefix could be removed from data structure

i.e.

                  'jpg': 'image/jpeg',
...
ext = fname[idx+1:]

It makes no sense to keep period prefix as you are not using this field other than as key for value It will improve readability and save 1 char for each extension :-)

https://github.com/belyalov/tinyweb/blob/4ea409cf004b6b684b452af486cbc8f4bd77ee80/tinyweb/static.py#L9-L19

belyalov commented 6 years ago

Could you please describe what are the benefits / issues you're trying to add/resolve? The most popular way how to extract file ext is:

>>> import os
>>> filename, file_extension = os.path.splitext('/path/to/somefile.ext')
>>> filename
'/path/to/somefile'
>>> file_extension
'.ext'

From stackoverflow.

0x7162 commented 6 years ago

The only benefit here is readability based on fact you are not using this extension to access any file. It is really minor issue - you can drop it easily :-)

belyalov commented 6 years ago

Could you please update your PR with unittests / solve conflicts to get this issue resolved?

belyalov commented 6 years ago

Closing due to no activity, feel free to reopen.