anki/qt/aqt
evandrocoan 020415efb9 Replaced the mediasrv.py SimpleHttp server by flask and waitress,
fixing HTML5 media support.
https://stackoverflow.com/questions/37044064/html-audio-cant-set-currenttime
https://stackoverflow.com/questions/21956683/enable-access-control-on-simple-http-server
https://stackoverflow.com/questions/5052635/what-is-relation-between-content-length-and-byte-ranges-in-http-1-1
https://stackoverflow.com/questions/16725907/google-app-engine-serving-mp3-for-audio-element-needs-content-range-header

I was trying to use HTML5 audio tag to display audios like:
```html
<audio id="elem_audio" src="myfile.mp3" controls></audio>
```
![image](https://user-images.githubusercontent.com/5332158/79063321-565b5500-7c77-11ea-9f8d-6e1df6f07892.png)

But the progress bar seek was not working. After researching, I found the problem was the HTML server not properly responding to the HTML5 header requests. The HTML server should respond to quite complicated things as 206 partial, properly handle keep-alive, provide media ranges and other HTTP headers: https://stackoverflow.com/questions/37044064/html-audio-cant-set-currenttime

To implement all these on the Simple HTTP server would be quite complicated. Then, instead, I imported the `flask` web server, which is quite simple and straight forward to use. Now, the back-end is using a secure complaint HTTP back-end:
1. https://palletsprojects.com/p/flask/
    > Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks.
    >
    > Flask offers suggestions, but doesn't enforce any dependencies or project layout. It is up to the developer to choose the tools and libraries they want to use. There are many extensions provided by the community that make adding new functionality easy.

1. https://docs.pylonsproject.org/projects/waitress/en/latest/
    > Waitress is meant to be a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones which live in the Python standard library. It runs on CPython on Unix and Windows under Python 2.7+ and Python 3.5+. It is also known to run on PyPy 1.6.0 on UNIX. It supports HTTP/1.0 and HTTP/1.1.

Right now, anki does not support fields passing file names directly to HTML audio tags, but this can be easily done with (https://github.com/ankitects/anki/pull 540 - Added arguments to the sound tag) plus the commit 826a97df61, the HTML5 audio tag can be used like this:
```html
// Audio = [sound:myfile.mp3|onlyfilename]
<audio id="elem_audio" src="{{Audio}}" controls controlsList="nodownload"></audio>
```
![image](https://user-images.githubusercontent.com/5332158/79063736-c539ad80-7c79-11ea-8420-40b72185f4e7.png)

# Conflicts:
#	qt/aqt/mediasrv.py
2020-07-02 13:51:49 -03:00
..
__init__.py shift+click on the graphs button to access old graphs for now 2020-06-30 20:07:46 +10:00
.gitignore basic night mode support 2020-01-23 17:27:07 +10:00
about.py add some more names to about.py 2020-06-01 06:27:14 +10:00
addcards.py hook: history_line 2020-06-08 20:47:01 +02:00
addons.py work around yet another qt bug 2020-06-24 11:12:45 +10:00
browser.py update edited/changed column labels 2020-06-29 18:34:03 +10:00
clayout.py add type hints 2020-06-25 17:27:52 +03:00
customstudy.py fix custom study not saving 2020-05-22 11:25:11 +10:00
dbcheck.py formatting 2020-06-09 14:07:39 +10:00
deckbrowser.py lint fixes 2020-06-02 17:58:14 +10:00
deckchooser.py add typehint to deckchooser.py 2020-06-11 14:19:36 +09:00
deckconf.py Add three deck config hooks 2020-05-22 21:24:05 +02:00
dyndeckconf.py use qconnect everywhere, and fix some typing issues 2020-05-04 13:23:08 +10:00
editcurrent.py add qconnect helper and some type hints 2020-01-16 07:41:23 +10:00
editor.py show clearer error when media db locked 2020-07-01 11:19:06 +10:00
emptycards.py add note/card removal to backend 2020-06-04 18:21:04 +10:00
errors.py use qconnect everywhere, and fix some typing issues 2020-05-04 13:23:08 +10:00
exporting.py add "immediate" progress back 2020-06-01 13:57:10 +10:00
fields.py do nothing if dropPos == idx 2020-05-26 18:59:53 +09:00
gui_hooks.py hook: history_line 2020-06-08 20:47:01 +02:00
importing.py add "immediate" progress back 2020-06-01 13:57:10 +10:00
legacy.py use keyword args for calls with more than one argument 2020-05-24 09:12:47 +10:00
main.py defer top toolbar drawing until after add-ons loaded 2020-07-02 10:23:14 +10:00
mediacheck.py rework progress handling 2020-06-01 13:57:10 +10:00
mediasrv.py Replaced the mediasrv.py SimpleHttp server by flask and waitress, 2020-07-02 13:51:49 -03:00
mediasync.py fix 'NoneType' object has no attribute 'latest_progress' 2020-06-09 09:07:41 +10:00
modelchooser.py use qconnect everywhere, and fix some typing issues 2020-05-04 13:23:08 +10:00
models.py drop mw.weakref usage in models.py for now 2020-05-20 13:53:34 +10:00
mpv.py Fix "make check" by defining dummy _register_callbacks method in MPVBase 2020-06-27 13:07:46 +03:00
overview.py use deck tree for new/review count calculation 2020-05-16 20:28:03 +10:00
pinnedmodules.py pin legacy modules 2020-06-08 11:12:51 +10:00
preferences.py formatting 2020-07-01 14:01:24 +10:00
previewer.py tidy up Qt import 2020-05-20 13:38:55 +10:00
profiles.py add option to disable media syncing 2020-07-01 11:35:24 +10:00
progress.py add progress to db check 2020-06-08 21:07:36 +10:00
py.typed mark anki and aqt modules as having typing info 2020-01-13 13:03:37 +10:00
qt.py new stubs don't require as many ignores 2020-06-02 17:56:32 +10:00
reviewer.py add note/card removal to backend 2020-06-04 18:21:04 +10:00
schema_change_tracker.py track changes in fields dialog as well 2020-05-15 13:59:44 +10:00
sound.py Replace mpv "idle" property with "end-file" event 2020-06-27 03:46:40 +03:00
stats.py shift+click on the graphs button to access old graphs for now 2020-06-30 20:07:46 +10:00
studydeck.py Strip name of added deck 2020-06-17 11:58:33 +02:00
sync.py lint fixes 2020-06-02 17:58:14 +10:00
tagedit.py handle default deck and filtered deck suppression in the backend 2020-05-15 21:21:10 +10:00
taglimit.py use qconnect everywhere, and fix some typing issues 2020-05-04 13:23:08 +10:00
taskman.py lint fixes 2020-06-01 13:57:10 +10:00
theme.py pare back dark mode support 2020-04-15 21:44:56 +10:00
toolbar.py change sync label to indicate sync state 2020-06-02 13:23:01 +10:00
tts.py fix audio getting stuck (2/2) 2020-03-15 09:34:04 +10:00
update.py tweaking the folder names again 2020-01-03 07:48:38 +10:00
utils.py Moved the utils.py new save/restore functions together 2020-06-08 16:23:32 -03:00
webview.py add option to webview to skip external browser open 2020-06-29 15:48:01 +10:00
winpaths.py tweaking the folder names again 2020-01-03 07:48:38 +10:00