Need to change Python HTML Template Language - html

I'm working on a project in PyCharm that involves Python, Flask and Jinja code, but PyCharm isn't recognizing the Jinja code when I go to preview the html pages. I've read that I need to change my Template Language to Jinja2 in PyCharm for it to work, but I believe it's only available for the professional version.
Is there a workaround of do I need to switch to another IDE? Thanks

Found a solution. In order for the jinja code to be recognized I needed to run the python app containing Flask code in the command line:
python application.py
This will generated a url in the terminal and clicking on it opened up the html page in my browser.
Make sure that the following lines are at the bottom of your python code:
if __name__ == '__main__':
app.run()

Related

How to deploy cesium-starter-app in Flask

I have a small web project running on a python flask microframework.
I have several .html pages working in the flask server with the #app.route method
#app.route('/')
def home():
return render_template('home.html')
and I want to be able to visualize a cesium-starter-app index.html as one of them to use it as a visualizer of some properties, i.e. position of a spacecraft.
To test if the server allows the cesium app to be displayed I have replaced one of the .html files of my web project with the index.html one provided in the project https://github.com/pjcozzi/cesium-starter-app and updated the browser but the page is blank.
I also copied the Source and ThirdParty folders and the server.js file to the same directory where the .html is located to see if this do the trick but it doesnt work.
Could you please advice me on how to proper deploy the cesium-starter-app (or any other cesium implementation that works) inside a Flask web?
Thanks in advance!

Call VS Code Extensions from within Java or Python Code

I'm working with an old, faulty API that gives me wrongly formatted JSON files. I found an VS Code Extension that fixes the received file. Is it somehow possible to call that Extension from my file. It is possible to place it in either my Java or Python code.
Thanks in advance.

python 3 - .swf to html

Is there a way to decompile flash files into html in python 3?
I'm using urllib to gather html data from a website and would like to include flash content .. in html format, as part of the rest of the html content, preferably without downloading the file.
The few packages available are old and not made for python 3 or are not web based.
There are many free online decompiler tools for this so I thought it would have been easier to find code for this.
Thanks in advance!
UPDATE
As a workaround solution I have found this:
http://www.nowrap.de/flare.html
Which is a command line swf to html converter. I'm considering calling it as a subprocess unless someone has a better idea?

How to connect Python to a html file

I have written some python code:
from bs4 import beautifulsoup
from urllib.request import urlopen
r = input()
html = urlopen("http://www.google.co.in/"+r._str_())
soup = beautifulsoup(html, "lxml")
print (soup)
How do I connect my python file into a html file?
Are there any links? (Like javascript)
Edit:
Well, by your comment, I think you mean using python as the backend server language and html as frontend (pretty much like any website).
For that solution, you have multiple ways to do it. You can create your server from scratch, using the base http.server from python 3 (see here for more informations).
You also have multiple ways to do a python-based server, including Frameworks, which are, by today, the best way to do it.
You already have multiple python frameworks that does the server job, letting you defining the routes, data processing etc..
These frameworks include Django, Flask, Bottle, or Tornado.
A good one to start doing the server-part in python is Flask. The syntax is quite easy to understand, it does the job well, and there's no extra over-complicated work to do. Also, the community is great. (See here for a good way to start learning using flask).
Old:
You need to be more precise. What do you want to achieve ?
What do you mean by "connect my python file into a html file" ?
HTML file is not something you can connect to, it's just a basic file.
If you meant to write the html response body into a file just take a look at this for file interaction. If not, please be more precise about your problem/question.

Using Django on Runnable. cant render a simple html

I'm trying to use django and render a simple html on Runnable. I guess I'm missing something obvious but I get the error "Template does not exist" all the time.
This is the code: runnable
Thanks in advance for your help.
You need to set TEMPLATE_DIRS var in Django Settings (Settings.py) like the code comment says, to let Django get all the templates successfully.
Put os.path.join(os.path.dirname(__file__),"templates") in the variable and import os.path in python. Make a templates folder inside your app folder, and move all the .html files there.