20 Nisan 2017 Perşembe

Ternary Operator in different programming Languages (TEK SATIRDA if else):

c , c++ :
---------------------------
? operatörü kullanılır.  şart ? deyim1 : deyim2;

value = <condition> ? <expression1> : <expression2>

int sayi;
const char *sonuc;
sayi = 14;
if (sayi < 10)
sonuc = " 0";
else
sonuc = "x";

  printf(sonuc);


yukardaki kodun eşdeğeri:

int sayi;
const char *sonuc;
sayi = 4;

sonuc = sayi < 10 ? " 0" : " ";

printf(sonuc);


python:
----------------------------------


<expression1> if <condition> else <expression2>
veya


value = <condition> and <expression1> or <expression2>


t = 0
if t == 0:
  m = 100
else:
  m = 5

yukardaki kodun eşdeğeri:


t = 0
m = 100 if t == 0 else 5

yukardaki kodun eşdeğeri:

 t = 0
m = t==0 and 100 or 5


kaynaklar:

http://stackoverflow.com/questions/394809/does-python-have-a-ternary-conditional-operator
http://stackoverflow.com/questions/8500374/python-statement-of-short-if-else
http://stackoverflow.com/questions/1686390/python-equivalent-of-short-form-if-in-c
http://www1.gantep.edu.tr/~bingul/c/index.php?ders=6


18 Nisan 2017 Salı

Django projesini Windows'ta Apache üzerinde yayına alma:
Django 1.10  , Python 3.6












1-)C:\xampp içinde xampp-control.exe dosyasından Apache'yi çalıştırın.Apache çalışıyorsa aşağıdaki işlemleri yap

2-) http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi adresinden
mod_wsgi‑4.5.15+ap24vc14‑cp36‑cp36m‑win32.whl dosyasını indir.Bu dosyayı winrar ile açıp
mod_wsgi/server içinde mod_wsgi.cp36-win32.pyd dosyaını çıkar.Bu dosayanın adını
mod_wsgi.so olarak değiştir.

3-) mod_wsgi.so dosyasını C:\xampp\apache\modules altına kopyala

4-) C:\xampp\apache\conf içinde httpd.conf dosyasını aç LoadModule yazan satırların altına

LoadModule wsgi_module modules/mod_wsgi.so

ekle


5-) C:\xampp\htdocs altına django projesi oluştur.örnek mysite olsun

6-) Bu django projesini Apache'ya tanıtmak için httpd.conf dosyasını aç, en altına
bu satırları ekle:

# Python WSGI interface module
<IfModule wsgi_module>
WSGIScriptAlias / "C:/xampp/htdocs/mysite/mysite/wsgi.py"
WSGIPythonPath "C:/xampp/htdocs/mysite"
<Directory "C:/xampp/htdocs/mysite">
Allow from all
</Directory>
</IfModule>


7-)xampp-control.exe dosyasından Apache'yi restart edin.

8-)browserda http://localhost/ yazdığınızda django projesi çalışacaktır.


kaynak:
https://www.youtube.com/watch?v=VnR5O4IjmOs
https://www.devbattles.com/en/sand/post-304-using+Apache+and+Python+WSGI+on+Windows