![]() It's not possible to do this with many websites these days. On a side note: would it be possible to save a webpage like this (iPhone 6S page) with all of the scrolling animations, embedded pictures and videos and all the rest? I've only tried creating a Web Archive using Safari, but it only saved the nice scrolling animation – not the embedded pictures and such. I suppose I could create a virtual machine, load up the site on it and then save it as a snapshot and use it whenever I want to offline, but that seems like quite a disproportionate solution for such a seemingly simple problem. This undoubtedly means that the webpage can run offline with no problem – I just need a way to save it properly. When I'm in Safari and I go offline, the webpage performs fine. I noticed something interesting, however. I just want to save the website and be able to use it offline. A couple of other things that I can't remember anymore.WebDumper – gives me a "Forbidden" error.Save as on Chrome as Webpage, Complete (.html) – messes up layout and functionality.HTTrack – doesn't preserve the webpage's functionality.Save as on Safari as Page Source (.html) – Completely messes the page up.Save as on Safari as a Web Archive (.webarchive) – doesn't preserve the page's functionality.I want to be able to use it offline, so I wanted to save it. It is able to render MathJax in realtime, without any noticeable lag. The website itself has some great functionality. This little API responds to the /time URL with a JSON payload such as this: from 'react' Ĭonst = useState(0) įetch('/time').then(res => res.json()).I've been trying to save this webpage using all of the methods that I know, but none of them have worked so far. Here is my Flask API project, written as a single file called api.py: import time In the spirit of keeping things simple, for this example I'm going to create a small, single file and single endpoint application. In particular, you can use large and complex structures such as those in my Flask Mega-Tutorial or O'Reilly Flask book, as well as much simpler single file applications. The Flask project can have any structure that you like, as long as its root is this new api subdirectory. If you are using Windows, then you will do this instead: $ python -m venv venvįor this simple example I need only two Python packages, the obvious Flask and also python-dotenv: (venv) $ pip install flask python-dotenv Note that the above is for Unix-based operating systems. I always create a virtual environment called venv in my project directory, so let's do that now: $ python3 -m venv venv Since I want to have both the frontend and backend combined into a single project, my preference here is to add one more top-level subdirectory where the Flask project will live: $ mkdir api The next step is to create the Flask project. rw-r-r- 1 mgrinberg staff 890 Feb 10 15:04 package.jsonĭrwxr-xr-x 8 mgrinberg staff 256 Feb 10 14:54 publicĭrwxr-xr-x 10 mgrinberg staff 320 Feb 10 23:50 src ![]() If you list the directory you should see the top-level structure, which should be more or less like this: $ ls -l Since you will work on this project from now on, you can cd into react-flask-app so that it is your current directory. When this command completes, you will have a react-flask-app directory with a complete and fully functional simple react project. The second argument is the name of the project to create. The first argument is the command to execute. It is a simple project runner that downloads the requested command if it isn't already available and in the system's PATH. For this example I used the create-react-app generator to create a simple React project to start from: $ npx create-react-app react-flask-app I prefer to start from the frontend because the project structure is much more complex than the backend. There are several ways to create a combined project with React and Flask. Please install these three packages using the instructions for your operating system before continuing with the tutorial. Python: A recent Python 3 interpreter to run the Flask backend on. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |