Simple static website can interact with database? - database

Let's say that I would like to build a very simple website which retrives the content from a database but instead of building a dynamic site, which should be deployed in a VPS or a PaaS I want it to be static so it can easily run in any kind of web hosting.
Is that possible? Maybe using a CDN library like axios or jquery?
Thanks!

Since static Web pages contain fixed code, the content of each page does not change unless it is manually updated by the webmaster. So what you asked for is not a static website.
You need to use at least one server-side programming language (like PHP) to make a connection to a database.
And about compatibility, you don't need to look around VPS or PaaS at the start point, depended on your PL (programming language) and database you can choose your web hosting service from shared hosting providers, as your website growing and you learn more about the web stacks you can think about the dedicated host on VPS or use cloud service and ...

Related

Is Single Page Application needs a Application Server?

I'm new to SPA development, so this may be a stupid question. please understand.
My question is "Is SPA(Single Page Application) needs a Application Server?"
As I understand it, the SPA gets the response after calling REST API. It use that response to re-render.
If so, is the server that handles REST API "Application Server"?
So many posts say Application Server are tomcat, oracle, etc... and they are also say Application Server handle the request to access the database. Then what is "Application Server" in SPA? or there are no Application Server in SPA?
(Are there any architectures or systems I'm not aware of?)
If I'm misunderstanding the architecture, please let me know.
I want to understand web server and Application Server in SPA. So I have read many posts but I'm still confused.
Thanks.
A SPA needs one server to serve the SPA bundle to the users browser.
If the SPA interacts with an API or APIs, the API(s) could be hosted on the same server that served the SPA bundle, or they could be hosted on other servers.
A Single Page App requires a server to serve the .css, index.html, and .js files it requires. It is not a requirement that that an SPA must communicate with an application server via any means at all.
Your content can be static or self generated by the app itself. Should you require communication with a backend server, you can consume that via some sort of api over
protocols such as http, https, websockets or Server Side Events.
To summarize. An SPA can be completely self contained OR access an api to provide functionality. A standalone app requires a server only to serve the component files (.css, .js, .html) of the app itself.
With SPA as well you will have html file and images, js, css files that will be loaded when you launch your single html webpage. So you need to host this static content on some server. So it can be separate web server or same APIs
server(Application Server) which can host these static content and serve request for those files. It can be also hosted on cloud static server and distributed via CDN
Short answer:
Yes. SPA apps do need to live somewhere (as you need to host the assets (js, css, initial html, other)
Long Answer:
You need to setup somewhere to host the entry files as per the short answer. In the past I've used anything from:
NodeJS code base services running on a Docker container (app & assets being served via express), to
dotnetcore on a similar stack (With kestrel server serving the assets running on docker on ec2).
Docker container running Apache webserver hosting the statically compiled assets
More recently I've dabbled with compiling the SPA app to a bunch of static assets (such as the ability NextJS / Gatsby provides with their tooling, but there are tons of others or alternatives in other SPA worlds)... but even then you'll need to host those assets somewhere.
S3 on Amazon has the ability to host SPA apps directly via a bucket setting & providing an entry point
Vercel (...or any other SaaS alternatives, Vercel is just where I host my personal stuff and has been easy to get going)
Again it's all up to you, but yes, you still need to make the JavaScript available somehow, you just need to pick your mechanic. SaaS with a baked in WebServer such as Vercel, a CDN like S3 that AWS provides, or go totally custom and spin up your own WebServer as application entry.

Reverse proxy between two (or more) Google App Engine projects

You have a Google Cloud project Project1 with App Engine enabled and serving your legacy application.
You want to rebuild your application using a different programming language and hence need a separate project (Project2) with its own separate App Engine.
You want to install some kind of reverse proxy appliance in front of your Project1 App Engine, so that you can gradually route more and more traffic to Project2's App Engine.
What's the best way to achieve this?
Google Cloud Load Balancer doesn't appear to work with App Engine (only Google Compute Engine), so I'm thinking establishing a reverse proxy server (e.g. NginX) container would be the best bet.
Depending on how you want to organize, you can duplicate your entire application within the same project by just deploying as a different service or as new versions of your existing service. For example, say you have two services frontend and backend for a simple web app. (Let's say they're both written in Python)
For deploying as a separate service, you can create a new version of your application in a different language, say Node.js. You can deploy the new services as frontend-node and backend-node.
If you don't want to do that, you can rewrite your application in a different language and then deploy as a new version of your existing services. In the "Versions" section, you can see your versions of the same service and they can be different language runtimes.
Either way, you can then use the "split-traffic" feature to customize and test implementations of your application.
Generally speaking, you should avoid using projects to isolate different variants and/or components of your application unless you really need too. App Engine services can each be a different runtime from each other so there's almost no point in provisioning a whole new project even though you're redeploying in a different language.

Hosting React/Redux Web Apps (front end)

One thing I do not quite understand yet is this. Say I have a website or single page app, made with React/Redux. Say I have no API calls or anything like this, so it's just the front-end I am talking about.
Do I have any restrictions when it comes to hosting?
People speak of Heroku & AWS here a lot, but as I understand it this concerns only the backend (?) Could I just host my React site with a 'traditional' provider or would I have to look out for something more specific?
There are no specific requirements for hosting a react JS webapp.
Let's say you're using webpack to build your webapp, it'll build a static javascript file that need to be served just like regular static assets.
So just the way you'd serve any other website that has static html/css/js assets.
That is the case when you've no special requirements. Now if you wish to build on the server you'd expect the server to run nodejs and have decent memory to support the build process. If you need to do caching/load balancing/rate limiting you'll have to use different required solutions.

How to deploy website on live server?

I have created a website on angularJS. I have local server running using nodeJS. Can anyone please tell me the further process to deploy the website.
Your local server is probably only for development purposes.
You can deploy it as usual application. All you need is web server. The most common selection is Apache, nginx or IIS. You can set up one of these on your own (on your own computer/VPS etc.) or use web hosting (just google it...).
Selecting correct solution depends on budget, needed support and number of users. I assume that usual "cheap web hosting" is the best for you.

Google App engine for mobile clients

Can I use GAE(Google App Engine) for developing a server for mobile clients? Mobile clients will send data to server every 10 seconds.
I am planning to develop the prototype using GAE and then depending on the results, will decide where to locate the prod server.
And are there any best practices to follow in developing code so that it will have very minimal dependancy with GAE (Can easily port to another environment with minimal code change when required)
thanks.
Ofcourse you can, GAE provides a good way to create a great backend for a mobile app.
about dependencies, you can use a project like django-nonrel, it creates an interface between your code and the API of GAE.

Resources