I am new to server side operations and have a personal project that I am building. I am running Python3, Django2 with mysql (which will be changed to postgres for live usage) and currently have my static files stored inside the virtualenv on my local drive. It's also built locally on Ubuntu 16.04 if this changes anything, for example: Maybe git deployment would be easiest?
My first question is: I don't expect lot's of traffic (under 1000 a day), and databases are very simple. Only an admin can upload static content, such as posts, images, tags and categories. Essentially a blog format. Where should I store these files? Amazon s3, azure, google, or anything you suggest
2. Second question is: Where should I host my web app, and how will it affect where I store my static files?
I'd like to note that I am an entrepreneur doing this on my own so an inexpensive and simple setup is what I am aiming for as I don't have much experience in server side tech, but willing to learn.
Thank you in advance for your time and sorry if I left out some required information, I'll update the Q as needed.
We store our static files on s3 using s3utils. You should also check out the this post, it describes how to set up an S3 bucket with the proper permissions.
We host our webapps on AWS Ec2 with Nginx and Gunicorn. Check out How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 16.04
Related
thanks in advance
I have a nginx server in which i am running python tornado application server. My tornado server conatins api endpoints(Handler), Models (DB table models) and the code for their respective services. We are using it as a backend service for an app that sells goods. Recently, we have implemented a complain feature that lets you upload image for the products.
I have to write code in python to convert base64 image into actual jpg/png (which is done), and then upload it to a different windows server(i m stuck in uploading part). I have been researching about it and found a few ways like
FTP
by RemoteDesktopConnection (it is clearly not for me)
and a few more.
if there is any better way to do this plz tell. i am not really experienced so plz explain your answers in a bit detail. Thank you for your time.
previously i was storing it in my application server which is clearly not a good thing to do and i was not able to expose the url for images also.
If it just needs to be a file in a directory on the other windows server, one could turn on file sharing for the specific directory on the other windows server and then smb mount that directory onto your application server. Then your python code could simply write a file to that directory.
A fairly good guide for doing this can be found here
Note that in a final production environment you want to be sure that the security is set appropriately (which is beyond the scope of this question).
So I have a bit of a issue, I want to use Heroku to host my flask web app, and then I also want to use Heroku pipeline to link to the GitHub repository where I am housing this project. The issue is that on my website I allow the user to upload files to the server, but I feel that If I were to update the GitHub repository I will lose all the files the user uploaded when the server reloads the new GitHub. I would like to know if this is a real issue and if so is there some way I could fix this?
Storing user-uploaded files to Heroku isn't a good idea because Heroku provides ephemeral filesystem.
The Heroku filesystem is ephemeral - that means that any changes to the filesystem whilst the dyno is running only last until that dyno is shut down or restarted. Each dyno boots with a clean copy of the filesystem from the most recent deploy. This is similar to how many container based systems, such as Docker, operate.
So even if you just restart your app, Users will lose their files. But they provide some alternate options to store these. As you are using python this Addon may help you.
Read More - https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted
I have a flask app with simple functionalities of a blog website codes given in below Github repo -
https://github.com/vivanks/flaskhost
It's data like user login details and blogs are stored in my system MySql-server.
On local machine it's working perfectly fine.
Now I want it to be deployed over internet.
What I tried so far is :
Heroku but problem with heroku is it need some postgressql and my whole data is stored in MySQL so I can't conver it.
Hosting flask part on Heroku and Database on 000webhost.com but 000webhost don't allow to connect to database outside of 00webhost
Hosting on http://pythonanywhere.com/ but then again failed also It don't support import MySQLdb instead it supports sqlalchemy
I want some way or something stable way through which I can export my data stored in mysql and don't have to change my code.
It would be great if you provide step by step guide.
P.S I don't have problem paying small amount
This is a bit embarassing, but I'm a Django noob and I couldn't find a simple solution to this:
I have written a Django app in a local VM that I now want to deploy to a "production" server. App works like a charm locally.
Now my IT colleague has set up the server with Django and that also works fine. I can open it via the Web and I get the usual "Congratulations on your first Django-powered page". I can also log into the admin interface. The project has been created.
This is a very low-key mini project and I'm not too familiar with git, so we've decided to just push files via FTP. (And I want to stick with that if at all possible.) So I uploaded the app folder into the project folder and also adjusted the project's settings.py and urls.py.
However, nothing seems to be happening on the server's end. The welcome page is the same, the app does not show up in the admin interface and the URLs won't be resolved as hoped.
Any suggestions what I should have done / done differently?
You need to restart apache or whatever is running your django project. Your changes to py files are cached when you first load your server config (settings).
Any suggestions what I should have done / done differently?
You should be using git/jenkins/deployment techniques, I know you said you've decided not to use it but you're going to be missing out on important things like being able to keep track of changes and unit testing
Before Ember CLI, I use to create an index.html page within Django project, plus the App.js file and all seemed to be working great.
Now that Ember is using CLI, it seems that there is no easy way to integrate Ember CLI project within Django application.
So I read that people are recommending using Ember CLI to develop the front-end, and Django to develop the REST API. However deployment is not easy, because you need to copy the Ember dist folder under Django static folder, plus change all the static asset url under Ember app to point to Django static path.
So it seems that, there is no easy way to integrate the two into one single development process.
Do you guys, have any suggestions on how to integrate the development, and deployment process?
Thx.
For projects like this, you should use separate repositories for your server app and client app(s).
Consider a project that has 4 code repositories, 1 server and 3 clients:
myproject (A Django app written in Python that provides an API for clients)
myproject-web (The Ember.js web client written in JavaScript)
myproject-ios (An iOS client app written in Swift)
myproject-android (An Android client app written in Java)
The core app will be deployed to a server that is capable of hosting Python apps (e.g. uWSGI).
Because the Ember.js project is ultimately a static resource, you can serve it from pretty much anywhere (e.g. NGINX), and point it at a separate API server that hosts the Django project (e.g. https://app.myproject.com/api/). See documentation on configuring ember-django-adapter to use a custom API host: http://dustinfarris.com/ember-django-adapter/configuring/
iOS of course would be deployed to the Apple App Store, and the Android project would be deployed to Google Play.
Each repository is a separate codebase with different requirements and deployment strategies—which is why it is best to keep them separate, so you can think about them and work with them in isolation. Just because Django can handle static assets doesn't mean you should rely on it—trying to host an Ember.js project (or any other JS framework project) within a Django project is just overcomplicating things. Hope that helps.
I am currently implementing a Ember-CLI app served by Django.
Here are the steps that I followed:
On Django:
Create a sub-project in your django project (ie: ember)
Install django-redis-views that will serve your index.html from redis.
Create a S3 bucket + CDN on AWS (or other storage product) in order to store your assets
On Ember:
install ember-deploy-redis & ember-deploy-s3
Add credentials to config.deployment and correct fingerprint in your ember-cli-build.js
Deploy ember
Useful link:
Easy deployment using redis + CDN: http://ember-cli.github.io/ember-cli-deploy/
Pip package that help your retrieving your index.html stored on redis: https://github.com/kevinlondon/django-redis-views