Build definition for Django app in VSTS - python

I'm looking for a functional build definition for a Django 2.0.5 app in Visual Studio Team Services.
What I'm trying to do is deploying my Django application to Azure App Services trough CI/CD, and the process is running well (I mean, the files is being traspased to production), but, for some reason, my app doesn't starts and I'm getting a lot of errors. I guess I'm traspassing the wrong files, but I really don't know it.
Can someone please tell me what did you do to build a Django app with CI/CD in VSTS?
EDIT:
What I'm doing is use a default build definition for Python called "Python package", but customized. In one of the build steps, it calls to "setup.py" file. I created the file in the root folder of my repository, and I wrote the next code:
import os
import shutil
from distutils.dir_util import copy_tree
if not (os.path.exists('./dist')):
os.makedirs('dist')
else:
shutil.rmtree('./dist')
copy_tree(".", "./dist")
Ok, I know the code is ugly, and I need to write it in a better way, but is functional and it copy the entire project structure into the "./dist" directory. Later, the release proccess takes all these files and copy it to production environment. All this works Ok, but my app never starts. When I try to navigate my url, I receive a 404 error, and can't use any of the project routes.
Hope it helps, if not, I will put all the necessary details, thank's again.

Finally I found the problem. I didn't traspased the environment folder, and I has missed web.config file too.
Uploading the env folder and the web.config file fix the application.
ref: https://github.com/azureappserviceoss/djangoapp

Related

Qradar directory access

I want to access the folder /store/ariel/events/payloads/ in the Qradar directories from the App editor. I am trying the os.path.exists however it returns false however, the folder exists as well as the path is located if I run the script in the linux kernel of the Qradar. I would really appreciate if anyone can guide me on how to access the directories from the Qradar App Editor.
Can't do it, unfortunately.
In QRadar, Apps can only interact with the rest of the deployment via API calls.
The App Framework guide can provide some more details about what's available to App developers.

Is there a way to send a flask app to be run by someone who doesn't have any of the stuff installed?

To preface: I'm very very new to Flask/web frameworks and all.
For some CS schoolwork, I'm supposed to develop an application of some form for a teacher. What I have chosen to use to develop it is Flask. However, the teacher I'm sending it to is unfamiliar with Python and probably doesn't have any Flask dependencies or anything installed. So I was wondering if there was a way for me to send him something (like a .pyc) which will locally host/run the flask app on his computer easily? For the purposes of testing it and all prior to hosting it.
Check out "Frozen-Flask": https://pythonhosted.org/Frozen-Flask/
"Frozen-Flask freezes a Flask application into a set of static files. The result can be hosted without any server-side software other than a traditional web server."
You could deploy your website on a cloud platform, such as GCP or AWS. There are several free tier computer instances that can run your Python code and deploy your website. Here's a tutorial on hosting flask with GCP. It takes a bit to setup but learning how to deploy on the cloud is a really useful skill to acquire, in my opinion.
If you have your environment set up you could also let your teacher SSH into your PC (with restrictions) and check/run your code from there. Good luck!
You can use CZ_FREEZE package that converts your FLASK project into a sharable cross-platform app, such that the receiving end doesn't need to install the essential libraries first.
First, install the cz_freeze library using,
pip install cz_Freeze
Then in your main project folder create a setup.py file containing the following code,
from cx_Freeze import setup, Executable
# Include the name of all folder or files in your project folder that is necessary for the project excluding your main flask file.
# If there are multiple files, you can add them into a folder and then specify the folder name.
# In place of main.py file add your main flask file name
includefiles = [ 'templates', 'static', 'some_other_file.py']
includes = [ 'jinja2' , 'jinja2.ext']
excludes = ['Tkinter']
setup(
name='Sample Flask App',
version = '0.1',
description = 'Sample Flask App',
options = {'build_exe': {'excludes':excludes,'include_files':includefiles, 'includes':includes}},
executables = [Executable('main.py')]
)
Now from the terminal run,
python setup.py build
Now there should be a folder created with name build containing all the files that you mentioned as well as the packages of your virtual environment.
Run the project using the script file with the name of your main flask file.

Django: Push app from local server to production server via FTP

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

Update mac app source code

I wrote a python script and then made it into a mac app using a program called Platypus. I noticed that if I make changes to the python source file inside the app's Resources folder, the app itself isn't updated. I'm wondering if there is a way I can update the app's source code without having to create a whole new app. Thanks.
The actual source code is probably imbedded in the app itself.

Django install as local app

all. I am trying to use the Django-Plupload in my project(src:https://github.com/vellonce/django-plupload). And I need to customize the view.py of this external app. Since I am developing in my localhost and I need to deploy it on server in the future, I don't want it to stay in site package. Instead, I want to install it as local app. May I know what is the suitable way to do this?
Thank you.
If you need to modify it, download the source and include it in your project (you will have to check license terms of the package)
Simply paste the app folder inside your project and add it to "installed apps"

Categories

Resources