I wonder is there some optional configuration to the dev server to autorefresh page when files changed. I know that django dev server autoreload project when some changes appear but what i am looking for is refreshing the webpage like it is in for example meteor. I was googling a little and find some apps and plugins to ff and chrome.
Django is designed to web development so i suspect that such feature should be in the core of dev server. Is it?
No, dev server is just a simple server that accepts request, passes it to the django app and returns a response from the app. It is something different than you can find in some JavaScript libraries or frameworks, where data are held in browser and you only hot reload the source code and library regenerates the page using the same data.
Related
I have a Python application that's that has been working correctly as backend for my website, up to now I have been running it using "python manage.py runserver IP:8000" in CMD. However I would like it to start using HTTPS, but when I try to access through my browser on https://IP:PORT I get the following error:
You're accessing the development server over HTTPS, but it only
supports HTTP.
The server I am running all of this is a Windows Center 2019 DataCenter, normally on a linux environment I would just use NGINX+GUNICORN.
I was browsing possible solutions and stumbled upon this, however I already am using IIS to host a website (My frontend), so I needed to figure out how to host several websites for the same IP, I have now found this.
Long story short, I configured the new IIS website for it to access my django, I then changed the hostname since both frontend and the new backend will using the same ip and ports (80, 443).
But now I have hit a spot where I'm confused due to my lack of experience in IIS and networking. I can't seem to understand how the request will go through to my Python-Django APP.
Something important to mention on how I access the Django APP in the past.
Lets say my front end is https://pr.app.com, whenever any request needed to be made to the backend. I would ask for said information in http://pr.app.com:8000/APIService/..../
This is how the binding for my frontend looks like
And this is the binding for the new backend where I changed the hostname as the second guide linked said
Any guidance or help would be most appreciated,
Thanks in advance
*Update
So I tried pausing my frontend website and used these bindings on the new backend website, I was able to get a screen of Django meaning it seems to be working or at least communicating.
Now I would need to have the hostname of the backend (pr.abcapi.com) somehow refer or redirect to the hostname of the frontend (pr.abc.com).
How could I achieve this?
I want to build a static web page based on python as server side and React for frontend on glitch online programming environment but unable to do .
I tried to implement by using CDN link but unable to use efficiently . Apart from this, I also wanted to use MATERIAL UI but according to there website it says
Using this approach in production is discouraged though - the client has to download the entire library, regardless of which components are actually used, affecting performance and bandwidth utilization.
Please elaborate steps to do the same.
Im sorry if that's too simple, but I managed to do it reading this article:
https://towardsdatascience.com/build-deploy-a-react-flask-app-47a89a5d17d9
I use the framework Flask, but if you are using Django the process must be similar.
But I recomend building a API with python and communicate with the front-end through the fecth API from javascript, or axios on react. You'll even be able to work on the frontend and backend in two different servers if you want.
I have just started learning how to build small Web apps with Python and Flask but am having some issues with the workflow. The way I am currently developing is:
Make a change to the app (HTML, CSS, JS, Python Flask code etc)
Stop the server
Clear the browser cache to remove the old static assets
Start the server
Reload my app in the browser
This is becoming a complete chore. I have come from developing with Node/Express and React where I have been using nodemon (https://www.npmjs.com/package/nodemon) to monitor any application changes. The server restarts automatically as soon as you save your app, with any changes detected immediately being reflected in the browser.
Is there something like this for Flask?
From the answers given in the comments above, the solution is to run the Flask development server using the Flask CLI like so:
export FLASK_ENV=development
flask run
This runs the Flask reloader so changes to the Flask application and any HTML are updated when the page reloads.
To fix the problem of the browser caching css files which have to be cleared to see any changes, I referred to this Flask css not updating SO question and the comment by #Aylen.
Simply reload the Web page for your app using
Ctrl+shift+R
This reloads the page and clears the cache at the same time.
Can I run a python server on the same Apache PHP server in order to use charts etc. that are included in the python dash application?
The implementation now is as follows. Php server uses an iframe in order to depict the python web app that is running in the same ip but on different port, but there is a need to change it for security reasons.
You can use Apache as a proxy to an internal server.
Apache server or php interpreter don't use iframes, you're adding html code that the browser will use to embeed the python server provided webpage into an iframe.
You're not doing anything wrong but to me seems error prone.
I would use a new domain to the webpage provided by python and setup his security and certs like any other server/web.
You can add CSP, feature policy, cors policy, frame options, xss protection, strict transport...
It's posible to send a request to the server using php and display back on the webpage the fetched graphs.
I developed a python web app in flask and I'm trying to deploy it correctly on IIS.
Before i launch the app to production server I'm testing it on a VM.
All the steps i did:
Install IIS with CGI
With IIS installed, I download the web platform installer
I installed the WFastCGI for Python 3 (my version)
I configured the Handler Mappings and the CGI Settings to deploy my app, and is all fine.
The Website is all working, except one part. One of the functions of the website require execute a webdriver, in this case PhantomJS, with selenium python module.
The PhantomJS executable is on the root folder of the website:
PhantomJSPath = 'phantomjs/bin/phantomjs.exe'
But when i try to use declare the variable to select the webdriver his just don't run on IIS (when i open that specific page of that function it gives me a 500 ERROR, all the other pages work perfectly). The stupid thing is, when i execute by Flask development mode on port 5000 it just works perfectly.
browser = webdriver.PhantomJS(PhantomJSPath)
I tried a lot of stuff already like give all permissions to everyone on the web app folder and stuff like that. I think the problem is with IIS configuration or security settings.
I hope you can help me and all of the other people with the same issue ;) TY
Ok, i solved it. just configured the Website settings on IIS and Application pool to the specific path of the website, give all the permissions to the IIS user (IIS_USRS) and it works. Ty anyway!.
If you know any other ways to fix this issue just post. I Will mark if it works too.