I am working on a Python Django project in which in one of the app, I have to do a lot of DOM manipulations. Earlier, I was using jQuery for this purpose but I want to use VueJS because of its virtual DOM. I am using PyCharm Pro. I am not able to use .vue files inside PyCharm. Somehow, I mistakenly set the 'language setting' for .vue file to React RxJS (since Vue also supports RxJS). I then installed Vue plugin for PyCharm and restarted it. Still, I get the same error "Unidentified character <" in the template portion of Vue file. I found that VueJS is now supported with a plugin in PyCharm Pro (https://twitter.com/pycharm/status/848978918120058880).
Can someone tell me what I am missing? What changes in the project or PyCharm settings do I need to make?
Edit: If someone can, please provide any suggestions/alternative solutions to handle DOM manipulations other than jQuery.
Consider setting .vue files in PyCharm to be recognized as HTML files.
I'm currently using PyCharm for a Flask / Vue.js project.
This is what my 'File Types' settings look like for .vue files:
And this is what a .vue file looks like in PyCharm for me:
When you attempt to add the *.vue pattern as an HTML file type, you should be forced by PyCharm to reassign it from the React JSX file type, so you shouldn't need to worry about manually removing the *.vue pattern from the React JSX file type.
Related
I have a working python 3.9 Flask app. The latest Pycharm is my IDE. Yesterday I created a new app with a very similar structure. The old app runs and finds/loads all static content just as expected when run through the PyCharm debugger or from the command line with flask run.
The new app will "run" from PyCharm or flask run. It loads the main/home blueprint and serves the correct template. What it does not do is serve any css or js resources in the static folder. Rather, it tries to load them but each resource in the Brave developer tools window has the message:
Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
I have surveyed the file sizes for each css and js file. I have matched the lengths against the developer tools "network" tab response information and it looks like all the sizes match.
I have tried this with FireFox and it just says:
Loading failed for the <script> with source “http://127.0.0.1:5000/static/LIB/jquery/jquery.min.js”.
and the other resources.
I have deleted and recreated the node_modules and the .idea dirs.
Ideas?
Sigh, my problem was with setting the USE_X_SENDFILE Flask config variable. The dev server does not support it and honestly I don't know why I even included it. Removing it fixed my issues.
Thanks entirely to this post:
Flask development server with X-Sendfile
I'm developing a Python Flask webapp and I'm trying to convert some user uploaded pdfs to nicely formatted HTML, like the HTML that is being produced when you display a pdf inside an iframe.
I tried several things so far:
the pdfminer.six library, produced messy HTML,
trying to grab the produced HTML, when rendering a PDF with pdf.js, which is apparently hidden in a Shadow DOM with no access to its inner HTML
finally I came across pdf2htmlEX (https://github.com/pdf2htmlEX/pdf2htmlEX) which produced exactly what I wanted.
Locally, this solution worked great, however in the production state (Heroku) I was unable to install it correctly. The project is deprecated and the documentation is limited and terrible. The problem has something to do with broken dependencies.
So, how to convert PDFs to HTML effectively without losing any format using Python or any other tool?
Thanks a lots.
if anyone is willing to help me getting the pdf2htmlEX to work on heroku, leave a comment and I will post more details in a different post
This is not going to be trivial. But I'll give some pointers.
You need an app.json in which you define your buildpacks.
https://devcenter.heroku.com/articles/app-json-schema#buildpacks
If this project is available via apt it's going to be easy. You just use the Heroku's Apt buildpack define an Aptfile that says which packages it needs to install. Example
Then it installs it automatically and you are done.
If it is not available as a package you will need to create your own buildpack.
https://devcenter.heroku.com/articles/buildpack-api
Example used here.
Another solution is to dockerize your project and execute it as a docker container.
I am new to Django and was following the tutorial here (https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1.html#hello-world) to get my first application running. I could not reference my application so I decided to name everything exactly as is in the tutorial in another Python project. I am unable to import view from boards no matter what I do (change it to projectname.appname and a number of different variations that I found on here). I have tried this tutorial on another computer I do not have access to at the moment and can confirm that it works usually. Is this an issue with PyCharm/my Python environment?
Project Structure
Error I am receiving
Fixed
To resolve this I marked my Django Project Folder (not Python Project Folder) as root.
I'm trying to combine Sphinx on my Django development server. I know i could better use apache. But I can't use apache due to the fact that the project will be managed by someone else and the project needs to work as simple as possible. Without too many external libraries etc.
So i tried django-docs package and django.static.serve in my url. The HTML pages work, only the look of the pages is just plain html so the CSS isn't included. The documentation on django-docs is really bad and i can't seem to get it to work with the static files Sphinx created. I can't use sphinxdocs as well since it needs haystacks which will add to my external libraries.
I added django-docs to my installed apps and added this to my settings. With projectpath being the path to where my conf.py is located. I'm not sure if the location is right though. But the documentation isn't really clear at what i should fill in on the project path part. And i added the urls in my urlspatterns
DOCS_ROOT = os.path.join(PROJECT_PATH, '../docs/_build/html')
DOCS_ACCESS = 'staff'
url(r'^docs/', include('docs.urls')),
In sphinx doc the static files are located in the docs/_build/html/_static
I found the problem If anyone else has the issue. I had some other folders called static inside my docs folder. When i removed them it worked. So it was just me being a bit stupid.
I am trying out Python on Bluemix. To do this I decided to move an example from a book that worked fine on my Windows laptop. I created the Bluemix example app, then replaced the index.html with the html file from the sample and built my directory tree beneath the static directory. The server starts up fine and displays the intro html file as expected, but when I click on a link that should build my html page it displays the page as source code instead of executing it. On Windows this works perfectly. My call to the page looks like this:
My data.
I have heard that on Linux environments you sometimes need to point out the python executable, but what is the right location of that in a Bluemix environment? Another question would be if the .py file is set to executable, but I don't know how you set such a thing in Bluemix.
All help is appreciated.
You can't directly link to a Python file in a Python webapp. You should use something like Flask to serve your application. Flask can do routing for you.
Additionally, in Bluemix and other Platform as a Services' there is only a single binary entry point to your app. You can't have multiple binary entry points.
See this example app on how to deploy a Flask app.
Additionally, you can click the button below to directly deploy the example app to Bluemix.